Regression Statistics
Full Regression Statistics
RegressionTables.AbstractRegressionStatistic
— TypeAbstractRegressionStatistic encapsulates all regression statistics (e.g., number of observations, $R^2$, etc.). In most cases, the individual regression packages provide functions that access these, generally from the StatsAPI.jl package. If the function does not exist in the regression package, it is typically added in the extension to this package. Since some statistics are not relevant for all regressions, the value of the statistic is wrapped in a Union
with Nothing
to indicate that the value is not available.
To define a new regression statistic, three things are needed:
- A new type that is a subtype of
AbstractRegressionStatistic
- A constructor that takes a
RegressionModel
and returns the new type (ornothing
if the statistic is not available) - A
label
function that is dependent on theAbstractRenderType
and the type provided. This label is what is displayed in the left most column of the regression table.
It is also helpful to maintain consistency by defining the value as val
within the struct.
For example:
struct YMean <: RegressionTables.AbstractRegressionStatistic
val::Union{Float64, Nothing}
end
YMean(x::RegressionModel) = try
YMean(mean(x.model.rr.y))
catch
YMean(nothing)
end
RegressionTables.label(render::AbstractRenderType, x::Type{YMean}) = "Mean of Y"
Defined Types
RegressionTables.AIC
— TypeAIC
is the Akaike Information Criterion of the regression. Labels default to "AIC" for all tables.
RegressionTables.AICC
— TypeAICC
is the Corrected Akaike Information Criterion of the regression. Labels default to "AICC" for all tables.
RegressionTables.AbstractR2
— Typeabstract type AbstractR2 <: AbstractRegressionStatistic end
Parent type for all $R^2$ statistics. This is available to change the formatting of all $R^2$ statistics. For example, if the desired display for $R^2$ is in the percentage term, run:
Base.repr(render::AbstractRenderType, x::RegressionTable.AbstractR2; vargs...) = repr(render, x.val * 100; digits=2) * "%"
# add second definition since Latex needs % escaped
Base.repr(render::AbstractRenderType::RegressionTables.AbstractLatex, x::RegressionTable.AbstractR2; vargs...) = repr(render, x.val * 100; digits=2) * "\%"
RegressionTables.AdjPseudoR2
— TypeSee AdjR2McFadden
for details.
RegressionTables.AdjR2
— TypeAdjR2
is the Adjusted $R^2$ of the regression. Labels default to:
- "Adjusted R2" for
AbstractAscii
- "Adjusted $R^2$" for
AbstractLatex
- "Adjusted <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.AdjR2Deviance
— TypeAdjR2Deviance
is the Deviance Adjusted $R^2$ of the regression. Labels default to:
- "Deviance Adjusted R2" for
AbstractAscii
- "Deviance Adjusted $R^2$" for
AbstractLatex
- "Deviance Adjusted <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.AdjR2McFadden
— TypeAdjR2McFadden
is the McFadden Adjusted $R^2$ of the regression (often referred to as the Pseudo Adjusted $R^2$). Labels default to:
- "Pseudo Adjusted R2" for
AbstractAscii
- "Pseudo Adjusted $R^2$" for
AbstractLatex
- "Pseudo Adjusted <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.BIC
— TypeBIC
is the Bayesian Information Criterion of the regression. Labels default to "BIC" for all tables.
RegressionTables.DOF
— TypeDOF
is the remaining degrees of freedom in the regression. Labels default to "Degrees of Freedom" for all tables.
RegressionTables.FStat
— TypeFStat
is the F-statistic of the regression. Since the StatsAPI.jl package does not provide a function for this, it is up to each package extension to provide the relevant information. Labels default to:
- "F" for
AbstractAscii
- "$F$" for
AbstractLatex
- "<i>F</i>" for
AbstractHtml
the FStat
label is used in other labels, so changing it will change those labels as well.
RegressionTables.FStatIV
— TypeFStatIV
is the first-stage F-statistic of an IV regression. Since the StatsAPI.jl package does not provide a function for this, it is up to each package extension to provide the relevant information. Labels default to:
- "First-stage F statistic" for
AbstractAscii
- "First-stage $F$ statistic" for
AbstractLatex
- "First-stage <i>F</i> statistic" for
AbstractHtml
RegressionTables.FStatIVPValue
— TypeFStatIVPValue
is the p-value of the first-stage F-statistic of an IV regression. Since the StatsAPI.jl package does not provide a function for this, it is up to each package extension to provide the relevant information. Labels default to:
- "First-stage p value" for
AbstractAscii
- "First-stage $p$ value" for
AbstractLatex
- "First-stage <i>p</i> value" for
AbstractHtml
RegressionTables.FStatPValue
— TypeFStatPValue
is the p-value of the F-statistic of the regression. Since the StatsAPI.jl package does not provide a function for this, it is up to each package extension to provide the relevant information. Labels default to:
- "F p value" for
AbstractAscii
- "$F$ $p$ value" for
AbstractLatex
- "<i>F</i> <i>p</i> value" for
AbstractHtml
RegressionTables.LogLikelihood
— TypeLogLikelihood
is the log likelihood of the regression. Labels default to "Log Likelihood" for all tables.
RegressionTables.Nobs
— TypeNobs
is the number of observations in the regression. Labels default to:
- "N" for
AbstractAscii
- "$N$" for
AbstractLatex
- "<i>N</i>" for
AbstractHtml
RegressionTables.PseudoR2
— TypeSee R2McFadden
for details.
RegressionTables.R2
— TypeR2
is the $R^2$ of the regression. Labels default to:
- "R2" for
AbstractAscii
- "$R^2$" for
AbstractLatex
- "<i>R</i><sup>2</sup>" for
AbstractHtml
The label for R2
is used in other related statistics. So changing the label for R2
will change the label for other $R^2$ statistics as well.
RegressionTables.R2CoxSnell
— TypeR2CoxSnell
is the Cox-Snell $R^2$ of the regression. Labels default to:
- "Cox-Snell R2" for
AbstractAscii
- "Cox-Snell $R^2$" for
AbstractLatex
- "Cox-Snell <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.R2Deviance
— TypeR2Deviance
is the Deviance $R^2$ of the regression. Labels default to:
- "Deviance R2" for
AbstractAscii
- "Deviance $R^2$" for
AbstractLatex
- "Deviance <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.R2McFadden
— TypeR2McFadden
is the McFadden $R^2$ of the regression (often referred to as the Pseudo-$R^2$). Labels default to:
- "Pseudo R2" for
AbstractAscii
- "Pseudo $R^2$" for
AbstractLatex
- "Pseudo <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.R2Nagelkerke
— TypeR2Nagelkerke
is the Nagelkerke $R^2$ of the regression. Labels default to:
- "Nagelkerke R2" for
AbstractAscii
- "Nagelkerke $R^2$" for
AbstractLatex
- "Nagelkerke <i>R</i><sup>2</sup>" for
AbstractHtml
RegressionTables.R2Within
— TypeR2Within
is the within R-squared of a fixed effects regression. Since the StatsAPI.jl package does not provide a function for this, it is up to each package extension to provide the relevant information. Labels default to:
- "Within R2" for
AbstractAscii
- "Within $R^2$" for
AbstractLatex
- "Within <i>R</i><sup>2</sup>" for
AbstractHtml
Below or Under Statistic
RegressionTables.AbstractUnderStatistic
— Typeabstract type AbstractUnderStatistic end
The abstract type for statistics that are below or next to the coefficients (e.g., standard errors, t-statistics, confidence intervals, etc.). The default available values are:
New values can be added by subtyping AbstractUnderStatistic
and defining the struct and a constructor. The constructer should accept the standard error, the coefficient, and the degrees of freedom.
RegressionTables.ConfInt
— Typestruct ConfInt <: AbstractUnderStatistic
val::Tuple{Float64, Float64}
end
ConfInt(rr::RegressionModel, k::Int; level=0.95, standardize=false, vargs...)
The confidence interval of a coefficient. The default confidence level is 95% (can be changed by setting RegressionTable.default_confint_level(render::AbstractRenderType, rr) = 0.90
or similar).
RegressionTables.StdError
— Typestruct StdError <: AbstractUnderStatistic
val::Float64
end
StdError(rr::RegressionModel, k::Int; standardize=false, vargs...)
The standard error of a coefficient.
RegressionTables.TStat
— Typestruct TStat <: AbstractUnderStatistic
val::Float64
end
TStat(rr::RegressionModel, k::Int; vargs...)
The t-statistic of a coefficient.
Other Statistics
RegressionTables.CoefValue
— Typestruct CoefValue
val::Float64
pvalue::Float64
end
The value of a coefficient and its p-value.
RegressionTables.HasControls
— Typestruct HasControls
val::Bool
end
Indicates whether the regression has coefficients left out of the table. HasControls
is used as a label, which defaults to "Controls". This can be changed by setting
RegressionTables.label(render::AbstractRenderType, x::Type{RegressionTables.HasControls}) = $name
RegressionTables.RegressionNumbers
— Typestruct RegressionNumbers
val::Int
end
Used to define which column number the regression is in. Primarily, this is used to control how these values are displayed. The default displays these as ($i)
, which can be set by running
RegressionTables.number_regressions_decoration(render::AbstractRenderType, s) = "($s)"
RegressionTables.FixedEffectValue
— Typestruct FixedEffectValue
val::Bool
end
A simple store of true/false for whether a fixed effect is used in the regression, used to determine how to display the value. The default is "Yes"
and ""
, which can be changed by setting fe_value
.
RegressionTables.RandomEffectValue
— Typestruct RandomEffectValue
val::Real
end
A simple sotre of the random effect value, by default equal to the standard deviation of the random effect. Typically will then be displayed the same as other Float64
values.
RegressionTables.ClusterValue
— Typestruct ClusterValue
val::Int
end
A simple store of the number of clusters used in the regression. Typically will be displayed the same as other Bool
values (e.g., "Yes"
or ""
).