Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sandwich

Making Sandwiches with Bread and Meat


Description

Constructing sandwich covariance matrix estimators by multiplying bread and meat matrices.

Usage

sandwich(x, bread. = bread, meat. = meat, ...)

Arguments

x

a fitted model object.

bread.

either a bread matrix or a function for computing this via bread.(x).

meat.

either a bread matrix or a function for computing this via meat.(x, ...).

...

arguments passed to the meat function.

Details

sandwich is a simple convenience function that takes a bread matrix (i.e., estimator of the expectation of the negative derivative of the estimating functions) and a meat matrix (i.e., estimator of the variance of the estimating functions) and multiplies them to a sandwich with meat between two slices of bread. By default bread and meat are called.

Some theoretical background along with implementation details is introduced in Zeileis (2006) and also used in Zeileis et al. (2020).

Value

A matrix containing the sandwich covariance matrix estimate. Typically, this should be an k x k matrix corresponding to k parameters.

References

Zeileis A (2006). “Object-Oriented Computation of Sandwich Estimators.” Journal of Statistical Software, 16(9), 1–16. doi: 10.18637/jss.v016.i09

Zeileis A, Köll S, Graham N (2020). “Various Versatile Variances: An Object-Oriented Implementation of Clustered Covariances in R.” Journal of Statistical Software, 95(1), 1–36. doi: 10.18637/jss.v095.i01

See Also

Examples

x <- sin(1:10)
y <- rnorm(10)
fm <- lm(y ~ x)

sandwich(fm)
vcovHC(fm, type = "HC")

sandwich

Robust Covariance Matrix Estimators

v3.0-0
GPL-2 | GPL-3
Authors
Achim Zeileis [aut, cre] (<https://orcid.org/0000-0003-0918-3766>), Thomas Lumley [aut], Nathaniel Graham [ctb], Susanne Koell [ctb]
Initial release
2020-10-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.