The brms.mmrm
R package implements a mixed model of
repeated measures (MMRM), a popular and flexible model to analyze
continuous longitudinal outcomes (Mallinckrodt et
al. (2008), Mallinckrodt and Lipkovich
(2017)). brms.mmrm
focuses on marginal MMRMs for
randomized controlled parallel studies with discrete time points, where
each subject shares the same set of time points. Whereas the mmrm
package
is frequentist, brms.mmrm
fits models in Bayesian fashion
using brms
(Bürkner 2017).
The MMRM in brms.mmrm
is mathematically expressed as
follows. Subsequent sections define notation, data, parameters, and
priors.
\[ \begin{aligned} &y_i \stackrel{\text{ind}}{\sim} \text{Multivariate-Normal} \left (\text{mean} = X_{i} \beta, \ \text{covariance} = \text{diag}(\sigma) \cdot \Lambda \cdot \text{diag}(\sigma) \right ) \\ &\qquad \beta_p \stackrel{\text{ind}}{\sim} q_p() \\ &\qquad \Lambda \sim r() \\ &\qquad \tau = \log(\sigma) \\ &\qquad \qquad \tau_t \stackrel{\text{ind}}{\sim} s_t() \end{aligned} \]
brm_formula()
).The priors on the parameters depend on the prior
argument of brm_model()
and related functions. If priors
are not specified by the user, then the brms
package sets defaults. You can view the default priors using the get_prior()
function in brms
. See
the brms
for
information on how brms
sets
default priors.
brms.mmrm
, through brms
, fits
the model to the data using the Markov chain Monte Carlo (MCMC)
capabilities of Stan (Stan Development Team 2023). Please read https://mc-stan.org/users/documentation/ for more
details on the methodology of Stan.
The result of MCMC is a collection of draws from the full joint
posterior distribution of the parameters given the data. Individual
draws of scalar parameters such as \(\beta_3\) are considered draws from the
marginal posterior distribution of e.g. \(\beta_3\) given the data.
Inference in brms.mmrm
, uses the estimated marginal
posterior distribution of the mean response at each combination of study
arm and time point. The emmeans
package (Lenth 2016) derives these
marginal posteriors while averaging over other covariates as nuisance
parameters. During this averaging process, the levels of categorical
nuisance parameters are weighted proportionally to their frequencies in
the dataset (with wt.nuis = "proportional"
in
emmeans::ref_grid()
).
The brm_marginal_draws()
function, described in the
usage vignette, derives posterior draws of the marginals using posterior
draws of the model coefficients \(\beta_p\). Then, downstream functions like
brm_marginal_probabilities()
compute numerical summaries of
these marginal draws.
The model above supports subgroup analysis through the addition of a
categorical variable in the data to denote subgroup levels. To analyze
the subgroup, new fixed effects parameters \(\beta_p\) and columns of the model matrices
\(X_i\) are added to the model to
describe the additive effect of the subgroup and plausible two-way and
three-way interactions with treatment group, discrete time, and baseline
(if applicable). Marginal means may include subgroup-specific terms, and
model comparison via the widely applicable information criterion (WAIC)
and expected log predictive density (ELPD) is implemented via R packages
loo
and brms
(Gabry et
al. (2019), Gelman and Hill (2007),
Vehtari et al. (2017), Vehtari et al. (2019)).