Regression Statistics

Full Regression Statistics

RegressionTables.AbstractRegressionStatisticType

AbstractRegressionStatistic 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:

  1. A new type that is a subtype of AbstractRegressionStatistic
  2. A constructor that takes a RegressionModel and returns the new type (or nothing if the statistic is not available)
  3. A label function that is dependent on the AbstractRenderType 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 <: RegressionTable.AbstractRegressionStatistic
    val::Union{Float64, Nothing}
end
YMean(x::RegressionModel) = try
    YMean(mean(x.model.rr.y))
catch
    YMean(nothing)
end
RegressionTable.label(render::AbstractRenderType, x::Type{YMean}) = "Mean of Y"
source

Defined Types

RegressionTables.AICType

AIC is the Akaike Information Criterion of the regression. Labels default to "AIC" for all tables.

source
RegressionTables.AICCType

AICC is the Corrected Akaike Information Criterion of the regression. Labels default to "AICC" for all tables.

source
RegressionTables.AbstractR2Type
abstract 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) * "\%"
source
RegressionTables.AdjR2Type

AdjR2 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
source
RegressionTables.AdjR2DevianceType

AdjR2Deviance 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
source
RegressionTables.AdjR2McFaddenType

AdjR2McFadden 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
source
RegressionTables.BICType

BIC is the Bayesian Information Criterion of the regression. Labels default to "BIC" for all tables.

source
RegressionTables.DOFType

DOF is the remaining degrees of freedom in the regression. Labels default to "Degrees of Freedom" for all tables.

source
RegressionTables.FStatType

FStat 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
Note

the FStat label is used in other labels, so changing it will change those labels as well.

source
RegressionTables.FStatIVType

FStatIV 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
source
RegressionTables.FStatIVPValueType

FStatIVPValue 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
source
RegressionTables.FStatPValueType

FStatPValue 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
source
RegressionTables.NobsType

Nobs is the number of observations in the regression. Labels default to:

  • "N" for AbstractAscii
  • "$N$" for AbstractLatex
  • "<i>N</i>" for AbstractHtml
source
RegressionTables.R2Type

R2 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
Note

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.

source
RegressionTables.R2CoxSnellType

R2CoxSnell 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
source
RegressionTables.R2DevianceType

R2Deviance 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
source
RegressionTables.R2McFaddenType

R2McFadden 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
source
RegressionTables.R2NagelkerkeType

R2Nagelkerke 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
source
RegressionTables.R2WithinType

R2Within 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
source

Below or Under Statistic

RegressionTables.AbstractUnderStatisticType
abstract 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.

source
RegressionTables.ConfIntType
struct 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).

source
RegressionTables.StdErrorType
struct StdError <: AbstractUnderStatistic
    val::Float64
end
StdError(rr::RegressionModel, k::Int; standardize=false, vargs...)

The standard error of a coefficient.

source
RegressionTables.TStatType
struct TStat <: AbstractUnderStatistic
    val::Float64
end
TStat(rr::RegressionModel, k::Int; vargs...)

The t-statistic of a coefficient.

source

Other Statistics

RegressionTables.HasControlsType
struct 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
source
RegressionTables.RegressionNumbersType
struct 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)"
source
RegressionTables.FixedEffectValueType
struct 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.

source
RegressionTables.RandomEffectValueType
struct 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.

source
RegressionTables.ClusterValueType
struct 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 "").

source