Skip to contents

Returns the \(D \times D\) variance-covariance matrix of the fixed-effect parameter vector.

Usage

# S3 method for class 'hbb_fit'
vcov(object, sandwich = NULL, ...)

Arguments

object

An object of class "hbb_fit" returned by hbb.

sandwich

An optional object of class "hbb_sandwich" returned by sandwich_variance, or NULL (default).

If provided:

The design-consistent sandwich variance \(V_{\mathrm{sand}} = H_{\mathrm{obs}}^{-1}\, J_{\mathrm{cluster}}\, H_{\mathrm{obs}}^{-1}\) is returned. This is the recommended choice for survey-weighted models.

If NULL:

The MCMC posterior covariance \(\Sigma_{\mathrm{MCMC}} = \mathrm{Cov}(\theta^{(m)})\) is returned. For hierarchical models this is prior-dominated and should be used only for unweighted base models.

...

Currently unused; included for S3 method consistency.

Value

A named numeric matrix of dimension \(D \times D\) where \(D = 2P + 1\). Row and column names are human-readable parameter labels (e.g., alpha_intercept, beta_poverty, log_kappa).

Warning – prior domination

For hierarchical models with state-varying coefficients, \(\Sigma_{\mathrm{MCMC}}\) absorbs prior and random-effect variance, producing Prior Inflation ratios of 600–6500 for fixed effects (see the sandwich variance documentation). Using \(\Sigma_{\mathrm{MCMC}}\) as a variance estimate will substantially over-cover. The sandwich variance is the appropriate measure of frequentist uncertainty.

Examples

if (FALSE) { # \dontrun{
fit <- hbb(y | trials(n_trial) ~ poverty + urban, data = my_data)
vcov(fit)  # MCMC posterior covariance

# With sandwich variance (recommended for survey data)
sand <- sandwich_variance(fit)
vcov(fit, sandwich = sand)
} # }