Methods

The brms.mmrm R package implements a mixed model of repeated measures (MMRM) (Mallinckrodt et al. 2008), a popular and flexible model to analyze continuous longitudinal outcomes. 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).

1 Model

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} \]

2 Notation

3 Data

4 Parameters

5 Priors

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.

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

7 Inference

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.

References

Bürkner, Paul-Christian. 2017. “brms: An R Package for Bayesian Multilevel Models Using Stan.” Journal of Statistical Software 80 (1): 1–28. https://doi.org/10.18637/jss.v080.i01.

Lenth, Russell V. 2016. “Least-Squares Means: The R Package Lsmeans.” Journal of Statistical Software 69 (1): 1–33. https://doi.org/10.18637/jss.v069.i01.

Mallinckrodt, C. H., P. W. Lane, D. Schnell, and others. 2008. “Recommendations for the Primary Analysis of Continuous Endpoints in Longitudinal Clinical Trials.” Ther Innov Regul Sci 42: 303–19. https://doi.org/10.1177/009286150804200402.

Stan Development Team. 2023. Stan Modeling Language Users Guide and Reference Manual (version 2.32.2). https://mc-stan.org.