Estimate Standardized Regression Coefficients and the Corresponding Robust Sampling Covariance Matrix Using the Heteroskedasticity Consistent Approach
Source:R/betaSandwich-beta-hc.R
BetaHC.RdEstimate Standardized Regression Coefficients and the Corresponding Robust Sampling Covariance Matrix Using the Heteroskedasticity Consistent Approach
Usage
BetaHC(
object,
type = "hc3",
alpha = c(0.05, 0.01, 0.001),
std_y = TRUE,
std_x = NULL,
g1 = 1,
g2 = 1.5,
k = 0.7
)Arguments
- object
Object of class
lm.- type
Character string. Correction type. Possible values are
"hc0","hc1","hc2","hc3","hc4","hc4m", and"hc5".- alpha
Numeric vector. Significance level \(\alpha\).
- std_y
Logical. Standardize \(y\). With
std_y = FALSE, \(y\) is left in its original units (\(b_j \sigma_{x_j}\)).- std_x
Character vector or
NULL. Names of the regressors to standardize.NULL(default) standardizes all regressors;character(0)standardizes none (\(b_j / \sigma_y\)). Leaving a dummy variable out keeps its 0-1 contrast. The delta method accounts for the sampling variability of the standard deviations.- g1
Numeric.
g1value fortype = "hc4m".- g2
Numeric.
g2value fortype = "hc4m".- k
Numeric. Constant
kfortype = "hc5"\(0 \leq k \leq 1\).
Value
Returns an object
of class betasandwich which is a list with the following elements:
- call
Function call.
- args
Function arguments.
- lm_process
Processed
lmobject.- gamma_n
Asymptotic covariance matrix of the sample covariance matrix assuming multivariate normality.
- gamma_hc
Asymptotic covariance matrix HC correction.
- gamma
Asymptotic covariance matrix of the sample covariance matrix.
- acov
Asymptotic covariance matrix of the standardized slopes.
- vcov
Sampling covariance matrix of the standardized slopes.
- est
Vector of standardized slopes.
Details
Partition the covariance matrix of the outcome and the regressors as
$$\boldsymbol{\Sigma} = \begin{pmatrix} \sigma^{2}_{y} &
\boldsymbol{\sigma}_{yx}^{\prime} \\ \boldsymbol{\sigma}_{yx} &
\boldsymbol{\Sigma}_{x} \end{pmatrix}.$$
The regression slopes and the standardized regression slopes are
$$\boldsymbol{\beta} = \boldsymbol{\Sigma}_{x}^{-1}
\boldsymbol{\sigma}_{yx}, \quad \beta^{\ast}_{j} = \beta_{j}
\frac{\sigma_{x_{j}}}{\sigma_{y}},$$
where \(\sigma_{x_{j}}\) is the standard deviation of regressor \(j\).
With std_y = FALSE, \(\sigma_{y}\) is replaced by one;
for a regressor left out of std_x, \(\sigma_{x_{j}}\) is replaced by one.
Let \(\boldsymbol{\theta}^{\ast}\) collect the standardized slopes,
\(\sigma_{y}\), the standard deviations of the regressors,
and the correlations of the regressors,
and let \(\boldsymbol{J} = \partial \operatorname{vech} \left(
\boldsymbol{\Sigma} \right) / \partial \boldsymbol{\theta}^{\ast \prime}\)
be the Jacobian of the implied covariance matrix,
evaluated at the estimates (Dudgeon, 2017).
The heteroskedasticity-consistent sampling covariance matrix is the
sandwich
$$\widehat{\operatorname{var}} \left( \hat{\boldsymbol{\theta}}^{\ast}
\right) = \frac{n}{\left( n - 1 \right)^{2}} \boldsymbol{B}^{-1}
\boldsymbol{J}^{\prime} \hat{\boldsymbol{\Gamma}}_{\mathrm{N}}^{-1}
\hat{\boldsymbol{\Gamma}}_{\mathrm{HC}}
\hat{\boldsymbol{\Gamma}}_{\mathrm{N}}^{-1} \boldsymbol{J}
\boldsymbol{B}^{-1}, \quad \boldsymbol{B} = \boldsymbol{J}^{\prime}
\hat{\boldsymbol{\Gamma}}_{\mathrm{N}}^{-1} \boldsymbol{J},$$
where \(\hat{\boldsymbol{\Gamma}}_{\mathrm{N}}\) is the normal-theory
matrix (see BetaN()) and
$$\hat{\boldsymbol{\Gamma}}_{\mathrm{HC}} = \frac{1}{n}
\sum_{i = 1}^{n} q_{i} \boldsymbol{v}_{i} \boldsymbol{v}_{i}^{\prime},
\quad \boldsymbol{v}_{i} = \operatorname{vech} \left( \boldsymbol{d}_{i}
\boldsymbol{d}_{i}^{\prime} \right) - \operatorname{vech} \left(
\boldsymbol{S} \right),$$
with \(\boldsymbol{d}_{i}\) the deviation of observation \(i\) from the
sample means.
The weight \(q_{i}\) depends on the leverage \(h_{i}\),
the number of regression parameters \(k\) (including the intercept),
and type:
\(q_{i} = 1\) ("hc0", "hc1"),
\(\left( 1 - h_{i} \right)^{-1}\) ("hc2"),
\(\left( 1 - h_{i} \right)^{-2}\) ("hc3"),
\(\left( 1 - h_{i} \right)^{-\delta_{i}}\) with
\(\delta_{i} = \min \left( 4, n h_{i} / k \right)\) ("hc4"),
\(\left( 1 - h_{i} \right)^{-\lambda_{i}}\) with
\(\lambda_{i} = \min \left( g_{1}, n h_{i} / k \right) + \min \left(
g_{2}, n h_{i} / k \right)\) ("hc4m"),
and \(\left( 1 - h_{i} \right)^{-\gamma_{i} / 2}\) with
\(\gamma_{i} = \min \left( n h_{i} / k, \max \left( 4, n c \max_{l}
h_{l} / k \right) \right)\) ("hc5", where \(c\) is the argument k).
With "hc1", the matrix is multiplied by \(n / \left( n - k \right)\).
The block of the standardized slopes is returned.
The confidence intervals are
\(\hat{\beta}^{\ast}_{j} \pm t_{1 - \alpha / 2, n - k}
\widehat{\operatorname{se}} \left( \hat{\beta}^{\ast}_{j} \right)\),
where \(k\) is the number of regression parameters,
including the intercept.
References
Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z
Pesigan, I. J. A., Sun, R. W., & Cheung, S. F. (2023). betaDelta and betaSandwich: Confidence intervals for standardized regression coefficients in R. Multivariate Behavioral Research. doi:10.1080/00273171.2023.2201277
See also
Other Beta Sandwich Functions:
BetaADF(),
BetaN(),
DeltaRSqSandwich(),
DiffBetaSandwich(),
FSqSandwich(),
PCorSandwich(),
RSqSandwich(),
SCorSandwich(),
SCorSqSandwich()
Examples
# Data ---------------------------------------------------------------------
data("nas1982", package = "betaSandwich")
# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
data = nas1982
)
# BetaHC -------------------------------------------------------------------
std <- BetaHC(object = object)
## Methods -----------------------------------------------------------------
print(x = std)
#> Call:
#> BetaHC(object = object)
#>
#> Standardized regression slopes with HC3 standard errors:
#> est se t df p 0.05% 0.5% 2.5% 97.5% 99.5%
#> NARTIC 0.4951 0.0786 6.3025 42 0.0000 0.2172 0.2832 0.3366 0.6537 0.7071
#> PCTGRT 0.3915 0.0818 4.7831 42 0.0000 0.1019 0.1707 0.2263 0.5567 0.6123
#> PCTSUPP 0.2632 0.0855 3.0786 42 0.0037 -0.0393 0.0325 0.0907 0.4358 0.4940
#> 99.95%
#> NARTIC 0.7731
#> PCTGRT 0.6810
#> PCTSUPP 0.5658
summary(object = std)
#> Call:
#> BetaHC(object = object)
#>
#> Standardized regression slopes with HC3 standard errors:
#> est se t df p 0.05% 0.5% 2.5% 97.5% 99.5%
#> NARTIC 0.4951 0.0786 6.3025 42 0.0000 0.2172 0.2832 0.3366 0.6537 0.7071
#> PCTGRT 0.3915 0.0818 4.7831 42 0.0000 0.1019 0.1707 0.2263 0.5567 0.6123
#> PCTSUPP 0.2632 0.0855 3.0786 42 0.0037 -0.0393 0.0325 0.0907 0.4358 0.4940
#> 99.95%
#> NARTIC 0.7731
#> PCTGRT 0.6810
#> PCTSUPP 0.5658
coef(object = std)
#> NARTIC PCTGRT PCTSUPP
#> 0.4951451 0.3914887 0.2632477
vcov(object = std)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.006172168 -0.003602529 -0.001943469
#> PCTGRT -0.003602529 0.006699155 -0.002443584
#> PCTSUPP -0.001943469 -0.002443584 0.007311625
confint(object = std, level = 0.95)
#> 2.5 % 97.5 %
#> NARTIC 0.33659828 0.6536920
#> PCTGRT 0.22631203 0.5566654
#> PCTSUPP 0.09068548 0.4358099