Model-Robust Variance Estimator for G-Computation
Source:vignettes/model_robust_estimator.Rmd
model_robust_estimator.RmdBackground
Suppose we have data from a randomized clinical trial comparing treatment groups. After fitting a particular MMRM, one must then commonly answer the question: what is the mean value of the outcome variable in each treatment group?
One method to answer this question is to use G-computation to estimate the marginal means of each treatment group. In this section, we describe the G-computation estimator in the context of the MMRM and a corresponding approach to variance estimation.
G-Computation Estimator
There are treatment groups, planned timepoints, and total subjects. Define as the row of the design matrix corresponding to subject , evaluated at timepoint if the subject had received treatment . In practice, this means that the design matrix columns corresponding to the treatment variable are set to the appropriate values for treatment - even when the subject actually received a different treatment in the trial.
The G-computation estimator of the mean outcome at time under treatment is Collect these into the vector . Treatment effects can then be defined by linear contrasts or other functions of .
Covariance Estimator of
The covariance matrix of can be decomposed using the law of total variance as:
Many variance estimators focus only on the first term. To enable a more general correct variance estimator that is robust to model misspecification, we need to add back the second term, which is related to the randomness of baseline covariates used in the design matrix.
To account for the extra source of variation from treating baseline covariates as random, define the vector of subject-level contributions to the G-computation estimator at time , with sample mean and sample covariance
Then if is the covariance estimator derived from the model while treating baseline variables as fixed (i.e. an estimate of the first term above), the overall covariance estimator that is robust to model misspecification is
Implementation
The G-computation estimator and corresponding covariance can be
implemented using the emmeans package. To enable correct
variance estimation, there is an argument
emmeans_gcomp_vars in mmrm_control() that
captures which variables can be treated as fixed or non-random. For
example, since every subject is predicted from the model at the same
time point and under each treatment, a model including TRTP
and AVISIT could include
emmeans_gcomp_vars = c("TRTP", "AVISIT").
Using emmeans with option
weights = "proportional" and passing in the
data with rows for every subject and timepoint can produce
.
Using
emmeans(fit, ~TRTP | AVISIT, weights = "proportional", data = data)the emmeans function will create a linear combination
matrix
.
For example, the row
of this matrix is
and the G-computation estimate is
.
Using the model-trusting variance, emmeans calculates the
coefficients covariance estimate
using vcov() and subsequently calculates
as the model-trusting covariance of the
G-computation estimator.
To work with emmeans functionality, we create a
model-robust coefficients covariance estimate
such that
where
is a block-diagonal matrix corresponding to the relevant empirical
covariance
at each time point.
This turns out to involve solving a linear system where represents the Moore-Penrose inverse of .