Model-robust standardization for cluster-randomized trials. The package estimates cluster-average and individual-average treatment effects and uses a delete-one-cluster jackknife for inference.
install.packages("MRStdCRT")MRStdCRT_fit() provides three model_weights
options for GEE, LMM, and GLMM working outcome models:
model_weights |
Outcome model for cATE | Outcome model for iATE |
|---|---|---|
"none" (default) |
Unweighted | Unweighted |
"inverse_cluster_size" |
Inverse-cluster-size weighted | Inverse-cluster-size weighted |
"estimand_specific" |
Inverse-cluster-size weighted | Unweighted |
The first two options use one fitted model for both estimands.
"estimand_specific" fits both models and returns the
weighted cATE, unweighted iATE, and their paired ICS test in a single
call. The cluster-summary GLM supports only "none".
library(MRStdCRT)
data(ppact)
fit <- MRStdCRT_fit(
PEGS ~ AGE + PEGS_bl, data = ppact,
cluster = "CLUST", trt = "INTERVENTION",
method = "GEE", family = gaussian(), corstr = "independence",
scale = "RD", model_weights = "inverse_cluster_size"
)
summary(fit)
estimand_specific_fit <- MRStdCRT_fit(
PEGS ~ AGE + PEGS_bl, data = ppact,
cluster = "CLUST", trt = "INTERVENTION",
method = "GEE", family = gaussian(), corstr = "independence",
scale = "RD", model_weights = "estimand_specific"
)
estimand_specific_fit$estimate
estimand_specific_fit$icsGEE uses an individual fitting weight of 1 / N_i, where
N_i is the observed number of individuals in cluster
i. Weighted LMM and GLMM use WeMix::mix() with
conditional individual weights of 1 and cluster weights of
1 / N_i. This weights each cluster’s integrated
log-likelihood contribution. Outcome values remain unchanged. Cluster
sizes and fitting weights are computed internally; the formula need not
contain cluster size or its interaction with treatment.
With "none" or "inverse_cluster_size", one
selected fitted model supplies counterfactual predictions for both
estimands. MRS retains the residual correction and uses equal cluster
weights for cATE and cluster-size weights for iATE. Every jackknife
sample refits the selected model. Weighted fitting is an additional
working-model option and does not guarantee improved efficiency.
With model_weights = "estimand_specific", both models
use the same formula, method, family, data, and treatment probabilities.
Each deletion removes the same cluster from both fits. The ICS test uses
the paired differences between the weighted cATE and unweighted iATE,
preserving their covariance. This requires two outcome-model fits on the
full data and two per deleted cluster. The existing unweighted LMM uses
REML, whereas its weighted counterpart uses maximum likelihood. The
selected model and its marginal-prediction procedure otherwise remain
the same. The unweighted component retains the existing warnings and
nonparametric fallback after a model-fitting error.
Weighted GEE supports Gaussian identity, binomial logit, and Poisson
log with independence or exchangeable working correlation. Weighted LMM
uses a Gaussian identity working model; weighted GLMM supports all three
family/link combinations with a single cluster random intercept. The
cluster-summary GLM supports only model_weights = "none".
Nonlinear mixed models with a random-intercept variance near zero can
fail numerically; an unverifiable fit stops the analysis with its
full-data or jackknife context.
See vignette("introduction", package = "MRStdCRT") for
fitting and prediction details, examples, and a GEE comparison with
cluster-size saturated g-computation.
For scale = "RR" or scale = "OR", set
inference_scale = "log" to construct a confidence interval
on the log scale and transform its endpoints back to the ratio scale.
The default, "original", retains inference on the original
effect scale. The log option applies to all supported working-model
methods and all three outcome-model weighting options. For
"estimand_specific", it uses the selected weighted cATE and
unweighted iATE estimates.
The log-scale standard error is computed from the logarithms of all
leave-one-cluster-out estimates. Confidence intervals and p-values use a
t distribution with one fewer degree of freedom than the number of
clusters. Point estimates, original-scale standard errors in
fit$estimate, and the paired ICS test are unchanged. The
additional standard errors are available as fit$log_se;
summary(fit) identifies the scales used for inference and
for the displayed standard errors.
Every full-data and deleted-cluster estimate must satisfy the relevant risk and ratio constraints. Invalid values stop the analysis; they are not truncated or omitted. The log option is unavailable for risk differences. Positive confidence limits do not guarantee better coverage in small samples. See the vignette for an executable comparison.
Li F, Tong J, Fang X, Cheng C, Kahan BC, Wang B (2025). Model-Robust Standardization in Cluster-Randomized Trials. Statistics in Medicine, 44, e70270. doi:10.1002/sim.70270.
Lee KM, Harhay MO, Li F (2026). Saturation in G: simple & robust causal inference in cluster randomized trials with informative cluster sizes. arXiv preprint. arXiv:2608.28943.
Bailey P, Webb B, Kelley C, Nguyen T, Huo H (2023). WeMix: Weighted Mixed-Effects Models Using Multilevel Pseudo Maximum Likelihood Estimation. R package version 4.0.3. doi:10.32614/CRAN.package.WeMix.
GPL-3.