Computes the design-corrected sandwich variance-covariance matrix for the fixed effects of a survey-weighted hurdle Beta-Binomial model. The estimator uses the stratified cluster-robust formula
Arguments
- fit
An object of class
"hbb_fit", as returned byhbb(). Must be a weighted model (model_type %in% c("weighted", "svc_weighted")), since score generated quantities are only produced by survey-weighted Stan models.
Value
An S3 object of class "hbb_sandwich" containing:
V_sandNumeric \(D \times D\) sandwich variance matrix.
H_obsNumeric \(D \times D\) observed Fisher information (block-diagonal: extensive \(P \times P\) and intensive+kappa \((P+1) \times (P+1)\)).
H_obs_invNumeric \(D \times D\) inverse of
H_obs, representing the data-only variance (no design correction).J_clusterNumeric \(D \times D\) cluster-robust meat matrix.
Sigma_MCMCNumeric \(D \times D\) posterior covariance of fixed-effect draws (for comparison, not used as bread).
scoresNumeric \(N \times D\) posterior mean score matrix.
DERNamed numeric vector of length \(D\). Design Effect Ratios: \(\mathrm{DER}_p = V_{\mathrm{sand}}[p,p] / H_{\mathrm{obs}}^{-1}[p,p]\).
param_labelsCharacter vector of length \(D\) with human-readable parameter labels.
DInteger. Total fixed-effect dimension.
NInteger. Number of observations.
PInteger. Number of covariates (including intercept).
model_typeCharacter. The model type from
fit.survey_infoList with survey design summaries:
n_strata,n_psu,df,n_singleton.matrix_diagnosticsList of eigenvalue/condition diagnostics for
H_obs,J_cluster,V_sand, andSigma_MCMC.nearPD_appliedLogical. Whether nearPD correction was applied to V_sand.
callThe matched call.
Details
$$V_{\mathrm{sand}} = H_{\mathrm{obs}}^{-1}\, J_{\mathrm{cluster}}\, H_{\mathrm{obs}}^{-1}$$
where \(H_{\mathrm{obs}}\) is the block-diagonal observed Fisher information (analytic for the extensive margin, empirical information identity for the intensive margin plus dispersion), and \(J_{\mathrm{cluster}}\) is the cluster-robust "meat" matrix that accounts for within-PSU correlation and unequal survey weights.
Why not Sigma_MCMC as bread
In hierarchical models with state random effects, the MCMC posterior covariance of fixed effects absorbs prior and random-effect variance, leading to \(\Sigma_{\mathrm{MCMC}} \gg H_{\mathrm{obs}}^{-1}\). Using \(\Sigma_{\mathrm{MCMC}}\) as bread yields astronomical Design Effect Ratios (3000–26000 in the NSECE application). The explicit \(H_{\mathrm{obs}}\) resolves this.
Fixed-effect parameter vector
The \(D = 2P + 1\) dimensional parameter vector is ordered as $$\theta = (\alpha_1, \ldots, \alpha_P,\; \beta_1, \ldots, \beta_P,\; \log\kappa)$$ where \(\alpha\) governs the extensive margin (Bernoulli), \(\beta\) governs the intensive margin (zero-truncated Beta-Binomial), and \(\kappa\) is the dispersion parameter.
Design Effect Ratio
The DER for each parameter is \(\mathrm{DER}_p = V_{\mathrm{sand}}[p,p] / H_{\mathrm{obs}}^{-1}[p,p]\). Expected values are 1–5 for typical survey designs.
References
Williams, M. R. and Savitsky, T. D. (2021). Uncertainty estimation for pseudo-Bayesian inference under complex sampling. International Statistical Review, 89(1), 72–107.
Examples
if (FALSE) { # \dontrun{
fit <- hbb(
y | trials(n_trial) ~ poverty + urban,
data = my_data, weights = "weight",
stratum = "vstratum", psu = "vpsu"
)
sand <- sandwich_variance(fit)
print(sand)
compute_der(sand)
} # }