Skip to contents

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), Holzhauer and Weber (2024)). brms.mmrm focuses on marginal MMRMs for randomized controlled parallel studies with discrete time points, where each patient 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).

Model

Let y1,,yNy_1, \ldots, y_N be independent data points observed for individual patients in a clinical trial. Each yny_n is a numeric vector of length TT, where TT is the number of discrete time points in the dataset (e.g. patient visits in the study protocol). We model yny_n as follows:

ynMultivariate-Normal(mean=Xnb,variance=Σn) \begin{aligned} y_n \sim \text{Multivariate-Normal}\left ( \text{mean} = X_n b, \ \text{variance} = \Sigma_n \right ) \end{aligned} Above, XnX_n is the fixed effect model matrix of patient nn, and its specific makeup is determined by arguments such as intercept and group in brm_formula(). bb is a constant-length vector of fixed effect parameters.

The MMRM in brms.mmrm is a distributional model, which means it uses a linear regression structure for both the mean and the variance of the multivariate normal likelihood. In particular, the T×TT \times T symmetric positive-definite residual covariance matrix Σn\Sigma_n of patient nn decomposes as follows:

Σn=diag(σn)Λdiag(σn)σn=exp(Znbσ) \begin{aligned} \Sigma_n &= \text{diag}(\sigma_n) \cdot \Lambda \cdot \text{diag}(\sigma_n) \\ \sigma_n &= \text{exp} \left ( Z_n b_\sigma \right) \end{aligned}

Above, σn\sigma_n is a vector of TT time-specific scalar standard deviations, and diag(σn)\text{diag}(\sigma_n) is a diagonal T×TT \times T matrix. ZnZ_n is a patient-specific matrix which controls how the distributional parameters bσb_\sigma map to the more intuitive standard deviation vector σn\sigma_n. The specific makeup of ZnZ_n is determined by the sigma argument of brm_formula(), which in turn is produced by brm_formula_sigma().

Λ\Lambda is a symmetric positive-definite correlation matrix with diagonal elements equal to 1 and off-diagonal elements between -1 and 1. The structure of Λ\Lambda depends on the correlation argument of brm_formula(), which could describe an unstructured parameterization, ARMA, compound symmetry, etc. These alternative structures and priors are available directly through brms. For specific details, please consult https://paulbuerkner.com/brms/reference/autocor-terms.html and ?brms.mmrm::brm_formula.

Priors

The scalar components of bb are modeled as independent with user-defined priors specified through the prior argument of brm_model(). The hyperparameters of these priors are constant. The default priors are improper uniform for non-intercept terms and a data-dependent Student-t distribution for the intercept. The variance-related distributional parameters bσb_\sigma are given similar priors

For the correlation matrix Λ\Lambda, the default prior in brms.mmrm is the LKJ correlation distribution with shape parameter equal to 1. This choice of prior is only valid for unstructured correlation matrices. Other correlation structures, such ARMA, will parameterize Λ\Lambda and allow users to set priors on those new specialized parameters.

Sampling

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 β3\beta_3 are considered draws from the marginal posterior distribution of e.g. β3\beta_3 given the data.

Imputation of missing outcomes

Under the missing at random (MAR) assumptions, MMRMs do not require imputation (Holzhauer and Weber (2024)). However, if the outcomes in your data are not missing at random, or if you are targeting an alternative estimand, then you may need to impute missing outcomes. brms.mmrm can leverage either of the two alternative solutions described at https://paulbuerkner.com/brms/articles/brms_missings.html. Please see the usage vignette for details on the implementation and interface.

References

Bürkner, P.-C. (2017), brms: An R package for Bayesian multilevel models using Stan,” Journal of Statistical Software, 80, 1–28. https://doi.org/10.18637/jss.v080.i01.
Holzhauer, B., and Weber, S. (2024), Bayesian Mixed effects Model for Repeated Measures,” in Applied Modeling in Drug Development, Novartis AG.
Mallinckrodt, C. H., Lane, P. W., Schnell, D., and others (2008), “Recommendations for the primary analysis of continuous endpoints in longitudinal clinical trials,” Therapeutic Innovation and Regulatory Science, 42, 303–319. https://doi.org/10.1177/009286150804200402.
Mallinckrodt, C. H., and Lipkovich, I. (2017), Analyzing longitudinal clinical trial data: A practical guide, CRC Press, Taylor; Francis Group.
Stan Development Team (2023), Stan modeling language users guide and reference manual.