hccm | R Documentation |
Calculates heteroscedasticity-corrected covariance matrices linear models fit by least squares or weighted least squares. These are also called “White-corrected” or “White-Huber” covariance matrices.
hccm(model, ...) ## S3 method for class 'lm' hccm(model, type=c("hc3", "hc0", "hc1", "hc2", "hc4"), singular.ok=TRUE, ...) ## Default S3 method: hccm(model, ...)
model |
a unweighted or weighted linear model, produced by |
type |
one of |
singular.ok |
if |
... |
arguments to pass to |
The original White-corrected coefficient covariance matrix ("hc0"
) for an unweighted model is
V(b) = inv(X'X) X' diag(e^2) X inv(X'X)
where e^2 are the squared residuals, and X is the model matrix. The other methods represent adjustments to this formula. If there are weights, these are incorporated in the corrected covariance matrix.
The function hccm.default
simply catches non-lm
objects.
See Freedman (2006) and Fox and Weisberg (2019, Sec. 5.1.2) for discussion of the use of these methods in generalized linear models or models with nonconstant variance.
The heteroscedasticity-corrected covariance matrix will be singular if one or more observations have hatvalues (leverages) equal to 1, and hence is not a consistent estimate of the population covariance matrix. This will occur most often in outlier testing: if there are m suspected outliers then m dummy variables are added to the regression model corresponding to the m cases (See Section 2.2.2 of Cook and Weisberg (1982)). The function returns an error if the heteroscedasticity-corrected covariance matrix is singular.
The heteroscedasticity-corrected covariance matrix for the model.
John Fox jfox@mcmaster.ca
Cook, R. D. and Weisberg, S. (1982). Residuals and Influence in Regression, Chapman and Hall, https://hdl.handle.net/11299/37076.
Cribari-Neto, F. (2004) Asymptotic inference under heteroskedasticity of unknown form. Computational Statistics and Data Analysis 45, 215–233.
Fox, J. (2016) Applied Regression Analysis and Generalized Linear Models, Third Edition. Sage.
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
Freedman, D. (2006) On the so-called "Huber sandwich estimator" and "robust standard errors", American Statistician, 60, 299–302.
Long, J. S. and Ervin, L. H. (2000) Using heteroscedasity consistent standard errors in the linear regression model. The American Statistician 54, 217–224.
White, H. (1980) A heteroskedastic consistent covariance matrix estimator and a direct test of heteroskedasticity. Econometrica 48, 817–838.
mod <- lm(interlocks ~ assets + nation, data=Ornstein) print(vcov(mod), digits=4) ## (Intercept) assets nationOTH nationUK nationUS ## (Intercept) 1.079e+00 -1.588e-05 -1.037e+00 -1.057e+00 -1.032e+00 ## assets -1.588e-05 1.642e-09 1.155e-05 1.362e-05 1.109e-05 ## nationOTH -1.037e+00 1.155e-05 7.019e+00 1.021e+00 1.003e+00 ## nationUK -1.057e+00 1.362e-05 1.021e+00 7.405e+00 1.017e+00 ## nationUS -1.032e+00 1.109e-05 1.003e+00 1.017e+00 2.128e+00 print(hccm(mod), digits=4) ## (Intercept) assets nationOTH nationUK nationUS ## (Intercept) 1.664e+00 -3.957e-05 -1.569e+00 -1.611e+00 -1.572e+00 ## assets -3.957e-05 6.752e-09 2.275e-05 3.051e-05 2.231e-05 ## nationOTH -1.569e+00 2.275e-05 8.209e+00 1.539e+00 1.520e+00 ## nationUK -1.611e+00 3.051e-05 1.539e+00 4.476e+00 1.543e+00 ## nationUS -1.572e+00 2.231e-05 1.520e+00 1.543e+00 1.946e+00
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.