This method for vcovHC computes the cluster-robust
variance-covariance matrix for a glmmTMB model fitted with ML.
# S3 method for class 'glmmTMB'
vcovHC(x, type = "HC0", sandwich = TRUE, ...)a glmmTMB object fitted with ML (REML is not supported).
only "HC0" is currently supported for glmmTMB models.
logical; if TRUE, return the sandwich estimator,
otherwise only the meat matrix is returned.
additional arguments passed to meatHC and
sandwich, in particular the full and cluster arguments are useful.
A square matrix representing the cluster-robust variance-covariance matrix.
The sandwich estimator is computed as B * M * B where
B is the bread matrix and M is the meat matrix.
The bread matrix is just the usual inverse Hessian obtained by
vcov(). The meat matrix is calculated as the sum of the cluster-wise
score vector cross-products.
m <- glmmTMB(count ~ mined + (1 | spp), data = Salamanders, family = nbinom1)
# Standard variance-covariance matrix:
vcov(m)$cond
#> (Intercept) minedno
#> (Intercept) 0.07473625 -0.02159957
#> minedno -0.02159957 0.02439405
# Cluster-robust variance-covariance matrix:
vcovHC(m)
#> (Intercept) minedno
#> (Intercept) 0.10060503 -0.03863554
#> minedno -0.03863554 0.04592111
# Include the variance parameters:
vcovHC(m, full = TRUE)
#> (Intercept) minedno disp~(Intercept) theta_1|spp.1
#> (Intercept) 0.10060503 -0.038635542 0.0263562511 -0.0469945945
#> minedno -0.03863554 0.045921110 -0.0044278894 -0.0064318964
#> disp~(Intercept) 0.02635625 -0.004427889 0.0350176956 -0.0005657375
#> theta_1|spp.1 -0.04699459 -0.006431896 -0.0005657375 0.0697818581
# This can be compared with:
vcov(m, full = TRUE)
#> (Intercept) minedno disp~(Intercept) theta_1|spp.1
#> (Intercept) 0.074736247 -0.0215995725 0.007442906 -0.0053396522
#> minedno -0.021599573 0.0243940499 -0.003287995 0.0007609193
#> disp~(Intercept) 0.007442906 -0.0032879946 0.018259553 -0.0021647850
#> theta_1|spp.1 -0.005339652 0.0007609193 -0.002164785 0.0902780102
# Only look at the meat part:
vcovHC(m, sandwich = FALSE)
#> (Intercept) minedno
#> (Intercept) 18.45719 18.72652
#> minedno 18.72652 98.85238