Skip to contents

Thin wrapper around sandwich variance estimators. Returns the requested variance-covariance matrix and the corresponding robust standard errors. Supports HC0-HC5 (cross-section), HAC (time-series), and clustered (one-way) variance.

Usage

morie_causal_robust_se(model, type = "HC3", cluster = NULL, ...)

Arguments

model

A fitted model object (typically from stats::lm or stats::glm) compatible with sandwich::vcovHC(), sandwich::vcovHAC(), or sandwich::vcovCL().

type

One of "HC0", "HC1", "HC2", "HC3", "HC4", "HC4m", "HC5", "HAC", or "CL" (clustered). Default "HC3" (Long-Ervin small-sample default).

cluster

Optional one-sided formula or vector identifying the cluster variable (required when type = "CL").

...

Additional arguments forwarded to the chosen sandwich estimator.

Value

Named list with elements vcov (variance matrix), se (named numeric vector of robust SEs), type, and n_coef.

Details

Hard-errors if sandwich is not installed – the HC sandwich algebra is well-tested upstream and re-implementing it inline would be both lengthy and error-prone.

References

Zeileis A, Koll S, Graham N (2020). Various Versatile Variances: An Object-Oriented Implementation of Clustered Covariances in R. Journal of Statistical Software, 95(1), 1-36.