Learn R Programming

glmmTMB (version 1.1.13)

vcovHC.glmmTMB: Cluster Robust Variance-Covariance Matrix Estimator

Description

This method for vcovHC computes the cluster-robust variance-covariance matrix for a glmmTMB model fitted with ML.

Usage

# S3 method for glmmTMB
vcovHC(x, type = "HC0", sandwich = TRUE, ...)

Value

A square matrix representing the cluster-robust variance-covariance matrix.

Arguments

x

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

type

only "HC0" is currently supported for glmmTMB models.

sandwich

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.

Details

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.

Examples

Run this code
m <- glmmTMB(count ~ mined + (1 | spp), data = Salamanders, family = nbinom1)

# Standard variance-covariance matrix:
vcov(m)$cond

# Cluster-robust variance-covariance matrix:
vcovHC(m)

# Include the variance parameters:
vcovHC(m, full = TRUE)

# This can be compared with:
vcov(m, full = TRUE)

# Only look at the meat part:
vcovHC(m, sandwich = FALSE)

Run the code above in your browser using DataLab