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

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)
#>             (Intercept)     minedno
#> (Intercept)  0.06874873 -0.06773661
#> minedno     -0.06773661  0.07820712
sandwich(m, full = TRUE)
#>                   (Intercept)      minedno disp~(Intercept) theta_1|site.1
#> (Intercept)       0.068748728 -0.067736607      0.004885335    0.002120480
#> minedno          -0.067736607  0.078207115     -0.001230996   -0.013564061
#> disp~(Intercept)  0.004885335 -0.001230996      0.026214327   -0.008710087
#> theta_1|site.1    0.002120480 -0.013564061     -0.008710087    0.100767890