Robust Covariance Matrix Estimators

Object-oriented software for model-robust covariance matrix estimators. Starting out from the basic robust Eicker-Huber-White sandwich covariance methods include: heteroscedasticity-consistent (HC) covariances for cross-section data; heteroscedasticity- and autocorrelation-consistent (HAC) covariances for time series data (such as Andrews' kernel HAC, Newey-West, and WEAVE estimators); clustered covariances (one-way and multi-way); panel and panel-corrected covariances; outer-product-of-gradients covariances; and (clustered) bootstrap covariances. All methods are applicable to (generalized) linear model objects fitted by lm() and glm() but can also be adapted to other classes through S3 methods. Details can be found in Zeileis et al. (2020) , Zeileis (2004) and Zeileis (2006) .


Robust Covariance Matrix Estimators

Model-robust standard error estimators for cross-sectional, time series, clustered, panel, and longitudinal data. Modular object-oriented implementation with support for many model objects, including: lm, glm, fixest, survreg, coxph, mlogit, multinom, polr, clm, hurdle, zeroinfl, and beyond.

Sandwich covariances for general parametric models:

Central limit theorem and sandwich estimator

Object-oriented implementation in R:

library("sandwich")
library("lmtest")
data("PetersenCL", package = "sandwich")
m <- lm(y ~ x, data = PetersenCL)
coeftest(m, vcov = sandwich)
## 
## t test of coefficients:
## 
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.0297     0.0284    1.05      0.3    
## x             1.0348     0.0284   36.45   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
coeftest(m, vcov = vcovCL, cluster = ~ firm)
## 
## t test of coefficients:
## 
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.0297     0.0670    0.44     0.66    
## x             1.0348     0.0506   20.45   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sandwich")

3.1-3 by Achim Zeileis, 3 months ago


https://zeileis.codeberg.page/sandwich/


Report a bug at https://codeberg.org/zeileis/sandwich/issues


Browse source code at https://github.com/cran/sandwich


Authors: Achim Zeileis [aut, cre] (ORCID: , Thomas Lumley [aut] , Nathaniel Graham [ctb] , Susanne Koell [ctb]


Documentation:   PDF Manual  


GPL-2 | GPL-3 license


Imports stats, utils, zoo

Suggests AER, car, geepack, lattice, lme4, lmtest, MASS, multiwayvcov, parallel, pcse, plm, pscl, scatterplot3d, stats4, strucchange, survival


Imported by BFpack, CausalSpline, ClusterRandSSAdj, ConvergenceClubs, DChaos, DIDmultiplegtDYN, ExactMed, FindIt, GCCfactor, GLMpack, GenericML, Greg, HDTSA, IOLS, MAARTS, MLCausal, MRTAnalysis, ManyIVsNets, ModLR, ModTools, NonlinearDiD, NormData, OPSR, PeerPerformance, PlackettLuce, PointFore, PublicationBiasBenchmark, RCT2, RESI, Rchoice, RegCalReliab, RobinCar2, SimplexRegression, SimtablR, SpatialRDD, StackImpute, TTE, TrialEmulation, UKBAnalytica, WMFM, WeightIt, adrftools, adventr, aersn, aldvmm, apm, ardl.nardl, artma, autostsm, beeca, betareg, binsreg, causalOT, causalQual, causalSLSE, causalweight, censReg, chantrics, clubSandwich, cmprskcoxmsm, contdid, contrast, crch, crseEventStudy, crwbmetareg, ctlr, dLagM, dcce, ddecompose, drc, drcte, eventglm, fChange, facmodTS, factorEx, fdid, fglsnet, fixest, flexCountReg, funtimes, fxregime, gcmr, glmmTMB, glmx, glogis, gravity, grf, gtregression, highfrequency, iClick, interflex, invacost, ivdoctr, jtools, lavaSearch2, lax, lfe, lineartestr, lite, lmw, lpirfs, lpmec, maczic, maicplus, malp, matchMulti, maxLik, medflex, mhurdle, micsr, mixl, mlt, model4you, monotonicity, multcomp, multipleOutcomes, multiwayvcov, mzipmed, nonnest2, npcp, nse, optic, outreg, party, pcdid, plm, propertee, pubh, quickmatch, radiant.model, rddapp, rddtools, rdhte, rdlocrand, rdstagger, refitME, regmedint, regtools, reviser, rifreg, rigr, risks, rqlm, sampcompR, scDIFtest, semtree, sfaR, simglm, singleRcapture, slm, speccurvieR, spicy, ssym, statAPA, statuser, stdReg2, systemfit, tbm, tidyfinance, trajmsm, tram, tramicp, tramnet, trtf, tsdistributions, tseffects, tsgarch, tsissm, tsmarch, uncertainUCDP, varGuid, vcrpart, weibulltools, wildmeta.

Depended on by AER, CADFtest, COUNT, DiDforBigData, RcmdrMisc, cjoint, clusterSEs, dhglm, gKRLS, gfunctions, gmm, list, mediation, merDeriv, mfx, midasr, momentfit, prais, strucchange, strucchangeRcpp, vars.

Suggested by ALDEx3, ARDL, BioStatR, DoubleML, EDI, FinTS, HSAUR2, HSAUR3, MarkowitzR, MatchIt, PCRA, R4VN, SGDinference, SharpeR, SimEngine, SpatialInference, StratifiedMedicine, VizTest, asympDiag, broom, car, chandwich, clarify, comets, convergenceDFM, csdm, ctreeMI, ddml, dfadjust, dyn, dynlm, easyViz, easytable, emmeans, estimatr, evaluatellm, factorana, falsifyr, fastglm, finalfit, forestsearch, foresty, futurize, fwb, geex, getspanel, ggadjustedforest, ggeffects, healthequal, heteroTests, huxtable, insight, interactions, iop, ivreg, ivreg2r, kardl, lmtest, madness, magentabook, marginaleffects, margins, medfit, memisc, miceadds, mlt.docreg, modelbased, modelsummary, modmarg, nprobust, optweight, panelr, panglm, parameters, parglm, partykit, performance, prepost, progressify, pscl, psychotools, rifttable, rineq, riskCommunicator, sfa, sjPlot, skedastic, sketching, spatialreg, staggR, stargazer2, tangram, texreg, tptest, tstests, tukeytrend, underdisp, valueprhr, vasicekfit, vivainsights, wpa.


See at CRAN