mmrm

Daniel Sabanes Bove

(Statistical Engineering, Pharma Product Development Data Sciences, Roche)

2022-12-08

Acknowledgments

Authors:

  • Kevin Kunzmann (Boehringer Ingelheim)
  • Brian Matthew Lang (MSD)
  • Ya Wang (Gilead)
  • Julia Dedic (Roche)
  • Doug Kelkhoff (Roche)
  • Liming Li (Roche)

Thanks to:

  • Ben Bolker (McMaster University)
  • Software Engineering working group (SWE WG)
  • Gonzalo Duran Pacheco (Roche)
  • Craig Gower-Page (Roche)
  • Dinakar Kulkarni (Roche)
  • Davide Garolini (Roche)

Motivation

  • 2 years ago, we thought we had solved the MMRM problem, using lme4 and lmerTest
  • However in March this year, Gonzalo and Julia told us the bad news: this approach failed on their Ophthalmology data sets (slow, did not converge)
  • nlme does not give Satterthwaite adjusted degrees of freedom, has convergence issues, and with emmeans it is only approximate
  • Next we tried to extend glmmTMB to calculate Satterthwaite adjusted degrees of freedom, but it did not work

Idea

  • Because glmmTMB is always using a random effects representation, we cannot have a real unstructured model (uses \(\sigma = \varepsilon > 0\) trick)
  • We only want to fit a fixed effects model with a structured covariance matrix for each subject
  • The idea is then to use the Template Model Builder (TMB) directly - as it is also underlying glmmTMB - but code the exact model we want
  • We do this by implementing the log-likelihood in C++ using the TMB provided libraries

Advantages of TMB

  • Fast C++ framework for defining objective functions (Rcpp would have been alternative interface)
  • Automatic differentiation of the log-likelihood as a function of the variance parameters
  • We get the gradient and Hessian exactly and without additional coding
  • This can be used from the R side with the TMB interface and plugged into optimizers

Cross-industry collaboration

  • We created an initial prototype quickly and open sourced it on github.com/openpharma/mmrm
  • In parallel we assembled multiple other companies - many of them had also struggled to implement MMRM in R (crucial gap in toolbox so far)
  • This was the start of the Software Engineering working group (SWE WG)

Features

  • Linear model for dependent observations within independent subjects
  • Covariance structures for the dependent observations:
    • Unstructured, Toeplitz, AR1, compound symmetry, ante-dependence, spatial exponential
    • Allows group specific covariance estimates and weights
  • REML or ML estimation, using multiple optimizers if needed
  • emmeans interface for least square means
  • Satterthwaite adjusted degrees of freedom

Getting started

  • mmrm is on CRAN - use this as a starting point:
install.packages("mmrm")
library(mmrm)
fit <- mmrm(
  formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
  data = fev_data
)
summary(fit)
library(emmeans)
emmeans(fit, ~ ARMCD | AVISIT)

Outlook

  • We still have major features on our backlog:
    • Kenward-Roger (improved variance-covariance matrix, degrees of freedom)
    • Robust sandwich estimator for covariance matrix (important when not using unstructured covariance)
    • Type II and type III ANOVA tests
  • Working on comparison to other implementations
    • Parameter estimates, computation time, convergence, …
  • Please let us know what is missing in mmrm for you! And try it out :-)

Thank you! Questions?