hccme | R Documentation |
Computes an estimate of the n\times n covariance matrix Ω (assumed to be diagonal) of the random error vector of a linear regression model, using a specified method
hccme( mainlm, hcnum = c("3", "0", "1", "2", "4", "5", "6", "7", "4m", "5m", "const"), sandwich = FALSE, as_matrix = TRUE )
mainlm |
Either an object of |
hcnum |
A character corresponding to a subscript in the name of an HCCME according to the usual nomenclature \mathrm{HC\#}. Possible values are:
|
sandwich |
A logical, defaulting to \mathrm{Cov}{\hat{β}}=(X'X)^{-1}X'\hat{Ω}X(X'X)^{-1} should be returned instead of \mathrm{Cov}(ε)=\hat{Ω} |
as_matrix |
A logical, defaulting to |
A numeric matrix (if as_matrix
is TRUE
) or else a
numeric vector
vcovHC
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars) Omega_hat <- hccme(mtcars_lm, hcnum = "4") Cov_beta_hat <- hccme(mtcars_lm, hcnum = "4", sandwich = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.