Robust covariance matrix estimators for R models
open sourceGPL-2.0-only OR GPL-3.0-onlyfree
sandwich is an R package of model-robust (sandwich) covariance matrix estimators. Starting from the Eicker-Huber-White estimator it offers heteroscedasticity-consistent (HC) covariances for cross-section data, heteroscedasticity- and autocorrelation-consistent (HAC) covariances for time series (Andrews' kernel HAC, Newey-West and WEAVE), one-way and multi-way clustered covariances, panel and panel-corrected covariances, outer-product-of-gradients covariances and (clustered) bootstrap covariances. They work with models fitted by lm() and glm() and extend to other model classes through S3 methods. Achim Zeileis and Thomas Lumley wrote it; it's described in three papers in the Journal of Statistical Software.
Problems it solves
- get heteroscedasticity-robust standard errors for my regression in R
- cluster standard errors by firm and year in R
- Newey-West standard errors for a time series regression in R
Features
- heteroscedasticity-consistent (HC) covariances
- HAC covariances, including Newey-West and Andrews' kernel
- one-way and multi-way clustered standard errors
- panel, panel-corrected and bootstrap covariances
- works with lm() and glm(), extensible through S3 methods
