sandwich: Sandwich Estimator based on Bread and Meat Matrices

sandwichR Documentation

Sandwich Estimator based on Bread and Meat Matrices

Description

This (simplified) method for a new S3 generic based on sandwich computes the sandwich estimator for a fitted glmmTMB model.

Usage

sandwich(x, ...)

## Default S3 method:
sandwich(x, ...)

## S3 method for class 'glmmTMB'
sandwich(x, full = FALSE, cluster = getGroups(x), rawnames = FALSE, ...)

Arguments

x

a glmmTMB object fitted with ML (REML is not supported).

...

ignored by the glmmTMB method.

full

logical; if TRUE, return the full sandwich matrix including variance components, otherwise only the fixed effects part (if the model was fit with ML).

cluster

a factor indicating the cluster structure of the data.

rawnames

logical; if TRUE, keep the original names of the parameters as in the TMB object. By default, FALSE such that the names are sanitized to user friendly names.

Value

A square matrix representing the sandwich estimator.

Examples

m <- glmmTMB(count ~ mined + (1 | site), data = Salamanders, family = nbinom1)
sandwich(m)
sandwich(m, full = TRUE)

glmmTMB documentation built on Jan. 15, 2026, 9:07 a.m.