robustify {bucky} | R Documentation |
Robustify a model
Description
Create a robustified object that includes robust or clustered robust standard errors.
Usage
robustify(x, cluster, type, omega, ...)
Arguments
x |
A model of class |
cluster |
The variable on which to cluster (if any). If this is not specified,
unclustered robust standard errors using |
type |
A character string specifying the estimation type. The default for
linear models of class |
omega |
A vector or a function depending on the arguments ‘residuals’
(the working residuals of the model), ‘diaghat’ (the diagonal
of the corresponding hat matrix) and ‘df’ (the residual
degrees of freedom). For details, see |
... |
Any additional arguments to be passed to |
Details
This function creates a robustified
object containing the
model, coefficients, and variance-covariance matrix based on
vcovHC
or vcovCR
, respectively. If the cluster
option is specified, the variance-covariance matrix is computed using
vcovCR
with clustering on cluster
. If not, the
variance-covariance matrix is computed using
vcovHC
. For generating formatted tables of
regression coefficients, the outputted objects should be
compatible with the 'texreg' package. When used with lm
,
glm
or a few other types of models, these objects are also
compatible with the 'stargazer' package.
Value
An object of class robustified
with the method
attribute specifying the type of standard errors used.
References
Cameron, A. Colin, and Douglas L. Miller. “A Practitioner's Guide to Cluster-Robust Inference.” Journal of Human Resources 50, no. 2 (Spring 2015): 317-372. doi: 10.3368/jhr.50.2.317
See Also
See Also summary.robustified
, vcovHC
, vcovCR
and coeftest
.
Examples
## With clustering
clotting <- data.frame(
cl = 1: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)
robust.clot.model <- robustify(clot.model, cluster=cl)
robust.clot.model
summary(robust.clot.model)
## Without clustering
data(swiss)
model1 <- robustify(lm(Fertility ~ ., data = swiss))
model1
summary(model1)