# sandwich

> Robust covariance matrix estimators for R models

Source: https://talira.ai/catalog/sandwich-12h2yvdd
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / math / statistics](https://talira.ai/categories/libraries/math/statistics), [languages / r](https://talira.ai/categories/languages/r)
- Licence: GPL-2.0-only OR GPL-3.0-only[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [Achim Zeileis](https://talira.ai/orgs/achim-zeileis.md)

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.

## Links

- Website: https://zeileis.codeberg.page/sandwich/
- Codeberg: https://codeberg.org/zeileis/sandwich
- Docs: https://zeileis.codeberg.page/sandwich/

## 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

## Trust

Overall: 0.27 out of 1.
Signals: backing 0.30, extensibility 0.00.

- backed by Achim Zeileis

Warnings:

- activity not tracked: Talira doesn't read Codeberg repositories yet

## Sources

[^1]: https://cran.r-project.org/web/packages/sandwich/index.html (checked 28 Nov 2026)
