API of Underlying Functions

DataRow

RegressionTables.DataRowType
mutable struct DataRow{T<:AbstractRenderType} <: AbstractVector{String}
    data::Vector
    align::String
    colwidths::Vector{Int}
    print_underlines::Vector{Bool}
    render::T
end

DataRow(x::DataRow) = x

(::Type{T})(x::DataRow) where {T<:AbstractRenderType} = DataRow(x.data, x.align, x.colwidths, x.print_underlines, T())

function DataRow(
    data::Vector,
    align,
    colwidths,
    print_underlines,
    render::AbstractRenderType;
    combine_equals=false
)

function DataRow(
    data::Vector;
    align="l" * "r" ^ (length(data) - 1),
    colwidths=fill(0, length(data)),
    print_underlines=zeros(Bool, length(data)),
    render::AbstractRenderType=AsciiTable(),
    combine_equals=false
)

DataRow forms the fundamental element of a RegressionTable. For a user, these can be passed as additional elements to group or extralines in regtable. A DataRow is typed with an AbstractRenderType, which controls how the DataRow is displayed. The default is AsciiTable. The DataRow contains four other elements:

  • data::Vector: The data to be displayed in the row. Can be individual elements (e.g., [1, 2, 3]) or pairs with a range (e.g., [1 => 1:2, 2 => 3:4]), or a combination of the two.
  • align::String: A string of ('l', 'r', 'c'), one for each element of data, indicating that elements alignment.
  • colwidths::Vector{Int}: A vector of integers, one for each element of data, indicating the width of the column. Can calculate the widths automatically using calc_widths and update them with update_widths!.
  • print_underlines::Vector{Bool}: A vector of booleans, one for each element of data, indicating whether to print an underline under the element. This is useful for printing the header of a table.

DataRow is a subtype of AbstractVector{String}. It implements getindex and setindex!, which allows changing of individual elements.

Note

In most cases, it is not necessary to specify the render type for DataRow. While constructing a RegressionTable, the render type is changed to the render type of the RegressionTable.

Examples

julia> DataRow(["", "Group 1" => 2:3, "Group 2" => 4:5])
   Group 1   Group 2

julia> DataRow(["", "Group 1", "Group 1", "Group 2", "Group 2"]; combine_equals=true)
   Group 1   Group 2

julia> DataRow(["", "Group 1" => 2:3, "Group 2" => 4:5])
   Group 1   Group 2

julia> DataRow(["   ", "Group 1" => 2:3, "Group 2" => 4:5]; print_underlines=[false, false, true])
      Group 1   Group 2
                -------

julia> DataRow(["Group 0", "Group 1" => 2:3, "Group 2" => 4:5]; colwidths=[20, 20, 20], align="lcr", print_underlines=true)
Group 0                       Group 1                      Group 2
--------------------   --------------------   --------------------

julia> DataRow(["", "Group 1" => 2:3, "Group 2" => 4:5]; render=LatexTable())
 & \multicolumn{2}{r}{Group 1} & \multicolumn{2}{r}{Group 2} \\ 
source

RegressionTable

RegressionTables.RegressionTableType
mutable struct RegressionTable{T<:AbstractRenderType} <: AbstractMatrix{String}
    data::Vector{DataRow{T}}
    align::String
    render::T
    breaks::Vector{Int}
    colwidths::Vector{Int}
    vertical_gaps::Vector{Int}
end

RegressionTable(header::Vector, body::Matrix, args...; vargs...)
RegressionTable(
    header::Matrix,
    body::Matrix,
    render::T=AsciiTable();
    breaks=[size(header, 1)],
    align='l' * 'r' ^ (size(header, 2) - 1),
    colwidths=fill(0, size(header, 2)),
    header_align='l' * 'c' ^ (size(header, 2) - 1),
    extralines::Vector = DataRow[]
) where T<:AbstractRenderType

The general container. This provides some general information about the table. The DataRow handles the main printing, but this provides other necessary information, especially the break field, which is used to determine where to put the lines (e.g., \midrule in LaTeX).

  • data: A vector of DataRow objects.
  • align: A string of characters, one for each column, indicating the alignment of the column. The characters are l for left, c for center, and r for right.
  • render: The render type of the table. This must be the same as the render type of the DataRow objects and is used for convenience.
  • breaks: A vector of integers, indicating where to put the lines (e.g., \midrule in LaTeX). When displayed, the break will be placed after the line number is printed (breaks = [5] will print a break after the 5th line is printed).
  • colwidths: A vector of integers, one for each column, indicating the width of the column. Can calculate the widths automatically using calc_widths and update them with update_widths!.
  • vertical_gaps: A vector of integers, indicating where to put vertical gaps in the table. These are places where two underlined cells are not connected. This is necessary for Excel integration.

The RegressionTable is a subtype of the AbstractMatrix{String} type (though this functionality is somewhat experimental). Importantly, this implements getindex and setindex!, which means individual elements of the table can be modified after its construction. See examples below. It also allows a RegressionTable to be passed to a function that expects a matrix, for example, exporting to a DataFrame DataFrames.jl would be DataFrame(Matrix(tab), :auto). Note that this will not keep multicolumn, unerlines, etc. information, but could be useful for exporting to other formats.

This type also has two convenience constructors which might be helpful if using this package to print summary statistics.

Example

julia> df = RDatasets.dataset("datasets", "iris");

julia> df = describe(df, :mean, :std, :q25, :median, :q75; cols=["SepalLength", "SepalWidth", "PetalLength", "PetalWidth"]);

julia> t = RegressionTables.RegressionTable(names(df), Matrix(df))
 
----------------------------------------------------
variable       mean    std     q25    median    q75
----------------------------------------------------
SepalLength   5.843   0.828   5.100    5.800   6.400
SepalWidth    3.057   0.436   2.800    3.000   3.300
PetalLength   3.758   1.765   1.600    4.350   5.100
PetalWidth    1.199   0.762   0.300    1.300   1.800
----------------------------------------------------

julia> t[1, 2] = "Mean of Variable";

julia> t[2, 3] = 0;

julia> RegressionTables.update_widths!(t); # necessary if a column gets longer

julia> t
 
---------------------------------------------------------------
variable      Mean of Variable    std     q25    median    q75
---------------------------------------------------------------
SepalLength              5.843       0   5.100    5.800   6.400
SepalWidth               3.057   0.436   2.800    3.000   3.300
PetalLength              3.758   1.765   1.600    4.350   5.100
PetalWidth               1.199   0.762   0.300    1.300   1.800
---------------------------------------------------------------
source

Render Types

Ascii

RegressionTables.AbstractAsciiType
abstract type AbstractAscii <: AbstractRenderType end

The abstract type for most plain text rendering. Printing is defined using the AbstractAscii, so new tables (with different defaults) can be created by subtyping AbstractAscii with minimal effort.

source

Latex

RegressionTables.AbstractLatexType
abstract type AbstractLatex <: AbstractRenderType end

The abstract type for most plain text rendering. Printing is defined using the AbstractLatex, so new tables (with different defaults) can be created by subtyping AbstractLatex with minimal effort.

source

HTML

RegressionTables.AbstractHtmlType
abstract type AbstractHtml <: AbstractRenderType end

The abstract type for most plain text rendering. Printing is defined using the AbstractHtml, so new tables (with different defaults) can be created by subtyping AbstractHtml with minimal effort.

source

Coefficient Naming

RegressionTables.AbstractCoefNameType
abstract type AbstractCoefName end

These names largely mirror their equivalents in StatsModels.jl. The main difference here is that the names are always based on strings (instead of symbols). There are also several default functions that are resused (e.g., get and replace) to make relabeling coefficients easier.

AbstractCoefName simply acts as a parent type to the other types. The other types are:

Using the function get_coefname will return the appropriate type for the term.

source
RegressionTables.get_coefnameFunction
get_coefname(x::AbstractTerm)::CoefName
get_coefname(x::Term)::CoefName
get_coefname(x::InteractionTerm)::InteractedCoefName
get_coefname(x::InterceptTerm{H})::InterceptCoefName
get_coefname(x::CategoricalTerm)::CategoricalCoefName
source
RegressionTables.CategoricalCoefNameType
struct CategoricalCoefName <: AbstractCoefName
    name::String
    level::String
end

Used to store the name of a coefficient for a CategoricalTerm. The level is the level of the categorical. In other words, the name is the column name, the level is the category within that column.

In a regression, the display of categorical terms is typically displayed as "name: level". You can change how the categorical term is "equal" by changing the categorical_equal function. The default is ": ", but you can change: this by setting:

RegressionTables.categorical_equal(render::AbstractRenderType) = " = "
RegressionTables.categorical_equal(render::AbstractLatex) = " $=$ "

You can also change how the categorical term is displayed by changing the repr function. The default is:

Base.repr(render::AbstractRenderType, x::RegressionTables.CategoricalCoefName; args...) =
    "$(RegressionTables.value(x))$(RegressionTables.categorical_equal(render)) $(x.level)"
source
RegressionTables.CoefNameType
struct CoefName <: AbstractCoefName
    name::String
end

Used to store the name of a coefficient. This is used for Term, ContinuousTerm and FunctionTerm.

source
RegressionTables.FixedEffectCoefNameType
struct FixedEffectCoefName <: AbstractCoefName
    name::AbstractCoefName
end

Used to store the name of a coefficient for a FixedEffectTerm. The name is the name of the fixed effect. This allows a suffix to be applied later.

source
RegressionTables.InteractedCoefNameType
struct InteractedCoefName <: AbstractCoefName
    names::Vector
end

Used to store the different coefficient names that makes up an InteractionTerm. The internals of the vector are typically CoefName, but can also be strings.

In a regression, each element of the vector is typically displayed as "name1 & name2 & ..." (in AsciiTables). The separator is set by interaction_combine function, and the default varies based on AbstractRenderType:

  • For AbstractAscii, it defaults to " & "
  • For AbstractLaTeX, it defaults to " $\times$ "
  • For AbstractHtml, it defaults to " &times; "

You can change the separator by running:

RegressionTables.interaction_combine(render::$RenderType) = " & "

where $RenderType is the type of the renderer you want to change. For example, to change the output in AbstractLaTeX:

RegressionTables.interaction_combine(::AbstractLaTeX) = " \& "

You can control how interaction terms are displayed more generally by changing:

Base.repr(render::AbstractRenderType, x::RegressionTables.InteractedCoefName; args...) =
    join(RegressionTables.value.(x), RegressionTables.interaction_combine(render))

See Customization of Defaults for more details.

source
RegressionTables.InterceptCoefNameType
struct InterceptCoefName <: AbstractCoefName end

Used as a simple indicator for the existence of an intercept term. This allows relabeling of the intercept in all cases by setting

RegressionTables.label(::InterceptCoefName) = "My Intercept"

See Customization of Defaults for more details.

source
RegressionTables.RandomEffectCoefNameType
struct RandomEffectCoefName <: AbstractCoefName
    rhs::CoefName
    lhs::AbstractCoefName
    val::Float64
end

Used to store the name and the standard deviation of a coefficient for a RandomEffectTerm from MixedModels.jl. The standard deviation is stored since that is often the useful information on the relationship between rhs and lhs.

source

Utility Functions

RegressionTables.calc_widthsFunction
calc_widths(rows::Vector{DataRow{T}}) where {T<:AbstractRenderType}

Calculate the widths of each column in the table. For rows with multicolumn cells, the width of the multicolumn is divided evenly among the columns it spans.

source
RegressionTables.update_widths!Function
update_widths!(row::DataRow{T}, new_lengths=length.(repr.(T(), row.data))) where {T}

Updates the widths of each column in the row. If lengths are provided, then it should equate to the total number of columns in the table, not the number of elements in the row.

source
RegressionTables.value_posFunction
value_pos(nms, x::String)

Returns the position of the string x in the vector of strings or AbstractCoefName nms.

Example

julia> import RegressionTables: CoefName, InterceptCoefName, InteractedCoefName, CategoricalCoefName, value_pos

julia> nms = ["coef1", CoefName("coef2"), InterceptCoefName(), InteractedCoefName(["coef3", "coef4"]), InteractedCoefName([CoefName("coef1"), CoefName("coef3")]), CategoricalCoefName("coef5", "10"), CategoricalCoefName("coef5", "20")];

julia> value_pos(nms, "coef1")
1:1

julia> value_pos(nms, "coef2")
2:2

julia> value_pos(nms, "coef3")
Int64[]

julia> value_pos(nms, "coef3 & coef4")
4:4

julia> value_pos(nms, "(Intercept)")
3:3

julia> value_pos(nms, "coef1 & coef3")
5:5

julia> value_pos(nms, "coef5: 10")
6:6
source
value_pos(nms, x::Int)

Checks that x is a valid index for the vector of strings or AbstractCoefName nms and returns a range of x:x

source
value_pos(nms, x::UnitRange)

Checks that x is a valid index for the vector of strings or AbstractCoefName nms and returns x

source
value_pos(nms, x::BitVector)

Returns a vector of indices where x is true, called by the regex version of value_pos.

source
value_pos(nms, x::Regex)

Looks within each element of the vector nms (which is either a string or an AbstractCoefName) and returns a vector of indices where the regex x is found.

Example

julia> import RegressionTables: CoefName, InterceptCoefName, InteractedCoefName, CategoricalCoefName, value_pos

julia> nms = ["coef1", CoefName("coef2"), InterceptCoefName(), InteractedCoefName(["coef3", "coef4"]), InteractedCoefName([CoefName("coef1"), CoefName("coef3")]), CategoricalCoefName("coef5", "10"), CategoricalCoefName("coef5", "20")];

julia> value_pos(nms, r"coef1") == [1, 5]
true

julia> value_pos(nms, r"coef[1-3]") == [1, 2, 4, 5]
true

julia> value_pos(nms, r"coef[1-3] & coef4") == [4]
true

julia> value_pos(nms, r" & ") == [4, 5]
true

julia> value_pos(nms, r"coef5") == [6, 7]
true

julia> value_pos(nms, r"coef5: 10") == [6]
true
source
value_pos(nms, x::Nothing)

Returns an empty vector, called by the regex and string version of value_pos.

source
value_pos(nms, x::Symbol)

Expects a symbol of the form :last or :end and returns the last value of nms, both are included for consistency with the Tuple

Example

julia> import RegressionTables: CoefName, InterceptCoefName, InteractedCoefName, CategoricalCoefName, value_pos

julia> nms = ["coef1", CoefName("coef2"), InterceptCoefName(), InteractedCoefName(["coef3", "coef4"]), InteractedCoefName([CoefName("coef1"), CoefName("coef3")]), CategoricalCoefName("coef5", "10"), CategoricalCoefName("coef5", "20")];

julia> value_pos(nms, :last)
7:7

julia> value_pos(nms, :end)
7:7
source
value_pos(nms, x::Tuple{Symbol, Int})

Expects a tuple of the form (:last, n) or (:end, n). (:last, n) returns the last n values (1:5 with (:last, 2) is 4:5), while (:end, n) returns the last index minus n (1:5 with (:end, 2) is 3).

Example

julia> import RegressionTables: CoefName, InterceptCoefName, InteractedCoefName, CategoricalCoefName, value_pos

julia> nms = ["coef1", CoefName("coef2"), InterceptCoefName(), InteractedCoefName(["coef3", "coef4"]), InteractedCoefName([CoefName("coef1"), CoefName("coef3")]), CategoricalCoefName("coef5", "10"), CategoricalCoefName("coef5", "20")];

julia> value_pos(nms, (:last, 2))
6:7

julia> value_pos(nms, (:end, 2))
5:5
source
RegressionTables.combine_other_statisticsFunction
combine_other_statistics(combine_other_statistics(
    stats;
    fill_val=missing,
    print_fe_suffix=true,
    fixedeffects=Vector{String}(),
    labels=Dict{String, String}(),
    transform_labels=Dict{String, String}(),
    kwargs...
)

Takes vector of nothing or statistics and combines these into a single section. These stats should be a vector of pairs, so this function expects a vector of these vector pairs or nothing. The function will combine the pairs into a single matrix. The first matrix column is a list of unique names which are the first value of the pairs and the rest of the matrix is the last value of the pairs organized.

Arguments

  • stats is a Vector of Vector{Pair} or nothing that should be combined.
  • fill_val defaults to missing but is the default value if the statistic is not present in that regression. For example, with fixed effects this defaults to FixedEffectValue(false) if the fixed effect is not present in the regression.
  • fixedeffects is a Vector of fixed effects to include in the table. Defaults to Vector{String}(), which means all fixed effects are included. Can also be regex, integers or ranges to select which fixed effects
  • print_fe_suffix is a Bool that governs whether the fixed effects should be printed with a suffix. Defaults to true, which means the fixed effects will be printed as $X Fixed Effects. If false, the fixed effects will just be the fixed effect ($X).
  • labels is the labels from the main regtable, used to change the names of the names.
  • transform_labels is the transform_labels from the main regtable.
  • kwargs are any other kwargs passed to regtable, allowing for flexible arguments for truly custom type naming.
source
RegressionTables.build_nm_listFunction
build_nm_list(nms, keep)

Takes the list of strings or AbstractCoefName nms and returns a subset of nms that contains only the elements in keep. Will also reorder the elements that are kept based on the order of keep.

source
RegressionTables.add_blankFunction
add_blank(groups::Matrix, n)
add_blank(groups::Vector{Vector}, n)

Recursively checks whether the number of columns in groups (or the length of the vector groups) is less than n, if so, add a blank column (or element) to the left of the matrix (first element of the vector).

This is used to make sure a provided piece of data is at least n columns, fitting into the table.

source
RegressionTables.missing_varsFunction
missing_vars(table::RegressionModel, coefs::Vector)

Checks whether any of the coefficients in table are not in coefs, returns true if so, false otherwise.

source
RegressionTables.add_element!Function
add_element!(row::DataRow, val, align_i, colwidth_i, print_underline_i, i)

Adds an element to the row and is only called when combine_equals=true. This means that if the last element in the row is the same as the provided val, then the last element is extended to include the new column.

source
add_element!(row::DataRow, val::Pair, align_i, colwidth_i, print_underline_i, i)

Adds an element to the row and is only called when combine_equals=true. Since val is a pair, is is simply added to the row as is, this allows for the creation of two multicolumn cells that have the same information but are separate.

source
RegressionTables.find_vertical_gapsFunction
find_vertical_gaps(data::Vector{DataRow{T}}) where T

Finds locations in a vector of DataRow objects where there are vertical gaps. A "vertical gap" is a place where two underlined cells are not connected. If there is a gap, then there needs to be a space between the current column and the next column. This makes it unnecessary to have a final vertical gap since the table ends there.

source

How Types are Displayed

This section describes how different types are displayed. Throughout this package, repr(T(), x) where T is a concrete type of AbstractRenderType is used to convert something to a string. This allows two things.

  1. Since it is easy to create new AbstractRenderTypes, it is possible to create customized displays for almost anyway situation
  2. Since most things in this package are types, each can be customized
Base.reprFunction
Base.repr(render::AbstractRenderType, x; args...)

Will render x as a string

source
Base.repr(render::AbstractRenderType, x::Pair; args...)

By default, will render the first element of the pair according to the render type. In cases of AbstractLatex or AbstractHtml, uses the second element to determine number of columns to span.

source
Base.repr(render::AbstractRenderType, x::Int; args...)

By default, will render the integer with commas

source
Base.repr(render::AbstractRenderType, x::Float64; digits=default_digits(render, x), commas=true, str_format=nothing, args...)

By default, will render the float with commas and the default number of digits. If str_format is specified, will use that instead of digits and commas

source
Base.repr(render::AbstractRenderType, x::Nothing; args...)

By default, will render the nothing as an empty string

source
Base.repr(render::AbstractRenderType, x::Missing; args...)

By default, will render the missing as an empty string

source
Base.repr(render::AbstractRenderType, x::AbstractString; args...)

By default, will render the string as is

source
Base.repr(render::AbstractRenderType, x::Bool; args...)

By default, will render the boolean as "Yes" or ""

source
Base.repr(render::AbstractRenderType, x::AbstractRegressionStatistic; digits=default_digits(render, x), args...)

By default, will render the statistic with commas and the default number of digits

source
Base.repr(render::AbstractRenderType, x::AbstractR2; digits=default_digits(render, x), args...)

By default, will render the same as AbstractRegressionStatistic

source
Base.repr(render::AbstractRenderType, x::AbstractUnderStatistic; digits=default_digits(render, x), args...)

By default, will render with the default number of digits and surrounded by parentheses (1.234)

source
Base.repr(render::AbstractRenderType, x::ConfInt; digits=default_digits(render, x), args...)

By default, will render with the default number of digits and surrounded by parentheses (1.234, 5.678)

source
Base.repr(render::AbstractRenderType, x::CoefValue; digits=default_digits(render, x), args...)

By default, will render with the default number of digits and surrounded by parentheses and will call estim_decorator for the decoration

source
Base.repr(render::AbstractRenderType, x::Type{V}; args...) where {V <: AbstractRegressionStatistic}

By default, will call the label function related to the type

source
Base.repr(render::AbstractRenderType, x::Type{RegressionType}; args...)

By default, will call the label function related to the RegressionType

source
Base.repr(render::AbstractRenderType, x::Tuple; args...)

By default, will render the tuple with spaces between the elements

source
Base.repr(render::AbstractRenderType, x::AbstractCoefName; args...)

By default, will render the name of the coefficient, also see Regression Statistics

source
Base.repr(render::AbstractRenderType, x::FixedEffectCoefName; args...)

By default, will render the coefficient and add " Fixed Effects" as a suffix, also see Regression Statistics

source
Base.repr(render::AbstractRenderType, x::RandomEffectCoefName; args...)

By default, will render the coefficient and add the " Clustering" function as a separator, also see Regression Statistics

source
Base.repr(render::AbstractRenderType, x::InteractedCoefName; args...)

By default, will render the coefficient and add the interaction_combine function as a separator, also see Regression Statistics

source
Base.repr(render::AbstractRenderType, x::CategoricalCoefName; args...)

By default, will render the coefficient and add the categorical_equal function as a separator, also see Regression Statistics

source
Base.repr(render::AbstractRenderType, x::InterceptCoefName; args...)

By default, will render the coefficient as (Intercept), also see Regression Statistics

source
Base.repr(render::AbstractRenderType, x::HasControls; args...)

By default, will render the same as Bool ("Yes" and "")

source
Base.repr(render::AbstractRenderType, x::RegressionNumbers; args...)

By default, will render the number in parentheses (e.g., "(1)", "(2)"...)

source
Base.repr(render::AbstractRenderType, x::Type{V}; args...) where {V <: HasControls}

By default, will call the label function related to the type

source
Base.repr(render::AbstractRenderType, x::RegressionType; args...)

By default, will check if the RegressionType is an instrumental variable regression and call the label function related to the type. If it is an instrumental variable, will then call label_iv, otherwise it will call the related distribution.

source
Base.repr(render::AbstractRenderType, x::D; args...) where {D <: UnivariateDistribution}

Will print the distribution as is (e.g., Probit will be "Probit"), unless another function overrides this behavior (e.g., Normal, InverseGaussian, NegativeBinomial)

source
Base.repr(render::AbstractRenderType, x::InverseGaussian; args...)

By default, will be "Inverse Gaussian"

source
Base.repr(render::AbstractRenderType, x::NegativeBinomial; args...)

By default, will be "Negative Binomial"

source
Base.repr(render::AbstractRenderType, x::Normal; args...)

By default, will call label_ols

source
Base.repr(render::AbstractRenderType, x::RandomEffectCoefName; args...)

How to render a RandomEffectCoefName and defaults to the right hand side, then the separator, then the left hand side.

source
Base.repr(render::AbstractRenderType, x::FixedEffectValue; args...)

How to render a FixedEffectValue and defaults to calling fe_value

source
Base.repr(render::AbstractRenderType, x::ClusterValue; args...)

How to render a ClusterValue and defaults to how true and false is displayed.

If wanting to show the size of the clusters, run:

RegressionTables.repr(render::AbstractRenderType, x::ClusterValue; args...) = repr(render, value(x); args...)
source
Base.repr(render::AbstractRenderType, x::RandomEffectValue; args...)

How to render a RandomEffectValue and defaults to calling another render function, dependent on the type of the value

source

New RegressionModel Types

This package is designed to be generally compatible with the RegressionModel abstraction. It has special conditions defined around four commonly used packages (FixedEffectModels.jl, GLM.jl, GLFixedEffectModels.jl and MixedModels.jl). It is possible to add new models to this list, either by creating an extension for this package or by creating the necessary items in an independent package.

For any new RegressionModel, there may be a need to define the following functions for the package to work correctly. Many of these will work without any issues if following the StatsModels API, and many of the others are useful for customizing how the regression result is displayed. It is also possible to redefine how RegressionTables.AbstractRegressionStatistic are displayed.

RegressionTables._responsenameFunction
_responsename(x::RegressionModel)

Returns the name of the dependent variable in the regression model. The default is to return a parsed version of the left hand side of formula (RegressionTables._formula), but if that is not available, then it will return the StatsAPI.responsename function.

source
RegressionTables._coefnamesFunction
_coefnames(x::RegressionModel)

Returns a vector of the names of the coefficients in the regression model. The default is to return a parsed version of the formula (RegressionTables._formula), but if that is not available, then it will return the StatsAPI.coefnames function.

source
RegressionTables._coefFunction
_coef(x::RegressionModel)

Returns a vector of the coefficients in the regression model. By default, is just a passthrough for the coef function from the StatsModels package.

source
RegressionTables._stderrorFunction
_stderror(x::RegressionModel)

Returns a vector of the standard errors of the coefficients in the regression model. By default, is just a passthrough for the stderror function from the StatsModels package.

source
RegressionTables._dof_residualFunction
_dof_residual(x::RegressionModel)

Returns the degrees of freedom of the residuals in the regression model. By default, is just a passthrough for the dof_residual function from the StatsModels package.

source
RegressionTables.other_statsFunction
other_stats(rr::RegressionModel, s::Symbol)

Returns any other statistics to be displayed. This is used (if the appropriate extension is loaded) to display the fixed effects in a FixedEffectModel (or GLFixedEffectModel), clusters in those two, or Random Effects in a MixedModel. For other regressions, this returns nothing.

source
RegressionTables.can_standardizeFunction
can_standardize(x::RegressionModel)

Returns a boolean indicating whether the coefficients can be standardized. standardized coefficients are coefficients that are scaled by the standard deviation of the variables. This is useful for comparing the relative importance of the variables in the model.

This is only possible of the RegressionModel includes the model matrix or the standard deviation of the dependent variable. If the RegressionModel does not include either of these, then this function should return false.

See also RegressionTables.standardize_coef_values.

source
RegressionTables.standardize_coef_valuesFunction
standardize_coef_values(std_X, std_Y, val)

Standardizes the coefficients by the standard deviation of the variables. This is useful for comparing the relative importance of the variables in the model.

This function is only used if the RegressionTables.can_standardize function returns true.

Arguments

  • std_X::Real: The standard deviation of the independent variable.
  • std_Y::Real: The standard deviation of the dependent variable.
  • val::Real: The value to be standardized (either the coefficient or the standard error).
Note

If the standard deviation of the independent variable is 0, then the interpretation of the coefficient is how many standard deviations of the dependent variable away from 0 is the intercept. In this case, the function returns val / std_Y.

Otherwise, the function returns val * std_X / std_Y.

source
RegressionTables.RegressionTypeType
struct RegressionType{T}
    val::T
    is_iv::Bool
end

The type of the regression. val should be a distribution from the Distributions.jl package. is_iv indicates whether the regression is an instrumental variable regression. The default label for the regression type is "Estimator". The labels for individual regression types (e.g., "OLS", "Poisson") can be set by running:

RegressionTables.label_ols(render::AbstractRenderType) = $name
RegressionTables.label_iv(render::AbstractRenderType) = $name

Or for individual distributions by running:

Base.repr(render::AbstractRenderType, x::$Distribution; args...) = $Name
source