vcovCR {bucky} | R Documentation |
Clustered Robust Covariance Matrix Estimation
Description
Robust estimation of the covariance matrix of the coefficient estimates in regression models with clustering.
Usage
vcovCR(x, cluster = NULL, type = c("CR", "CR0", "CR1"))
Arguments
x |
A fitted model object. |
cluster |
A variable or expression giving the cluster for each observation. |
type |
A character string specifying the estimation type. For details see below. |
Details
The default type
of "CR" uses the same adjustment as 'Stata'.
The values of "CR0" and "CR1" are analogous to "HC0" and "HC1",
respectively, in vcovHC
.
Value
A matrix containing the covariance matrix estimate with attribute
type
giving the type
option used in estimating it.
See Also
See Also robust.summary
and vcovHC
.
Examples
clotting <- data.frame(
cl = rep(1:2,each=9),
u = c(5,10,15,20,30,40,60,80,100),
lot = c(118,58,42,35,27,25,21,19,18,
69,35,26,21,18,16,13,12,12))
clot.model <- glm(lot ~ log(u), data = clotting, family = Gamma)
vcovCR(clot.model, cluster=cl)
data(swiss)
model1 <- lm(Fertility ~ ., data = swiss)
## These should give the same answer
vcovCR(model1, cluster=1:nobs(model1), type="CR0")
sandwich::vcovHC(model1, type="HC0")
[Package bucky version 1.0.7 Index]