Skip to contents

Reproduces sandwich::vcovHC. The meat is \(X' \Omega X\) with \(\Omega\) the diagonal of adjusted squared residuals, and the small-sample adjustment set by type: HC0 (none), HC1 (\(n/(n-k)\)), HC2 (\(1/(1-h_i)\)), HC3 (\(1/(1-h_i)^2\)), HC4 (\(1/(1-h_i)^{\delta_i}\), \(\delta_i=\min(4, h_i/\bar h)\)), HC4m, HC5.

Usage

morie_vcov_hc(model, type = "HC3")

Arguments

model

A fitted lm or glm.

type

One of "HC3" (default), "HC0"-"HC5", "HC4m", or "const" (the classical estimator).

Value

The coefficient covariance matrix.

References

MacKinnon, J. G., & White, H. (1985). Some heteroskedasticity-consistent covariance matrix estimators. Journal of Econometrics, 29(3), 305-325.

Examples

m <- lm(mpg ~ wt + hp, data = mtcars)
morie_vcov_hc(m, "HC1")
#>              (Intercept)           wt            hp
#> (Intercept)  4.148289468 -1.093698573 -0.0021174032
#> wt          -1.093698573  0.424066330 -0.0018197929
#> hp          -0.002117403 -0.001819793  0.0000487394