A Robust and Comprehensive R Package for Implementing Mixed Models for Repeated Measures
on Behalf of ASA BIOP Software Engineering Working Group (SWE WG)
2023-08-08
mmrm Package
mmrm package to SASlme4 with lmerTest, learned that this approach failed on large data sets (slow, did not converge)nlme does not give Satterthwaite adjusted degrees of freedom, has convergence issues, and with emmeans it is only approximateglmmTMB to calculate Satterthwaite adjusted degrees of freedom, but it did not workTMB) directly - as it is also underlying glmmTMB - but code the exact model we wantC++ using the TMB provided librariesTMBC++ framework for defining objective functions (Rcpp would have been alternative interface)TMB interface and plugged into optimizersmmrmemmeans interface for least square meanstidymodels for easy model fittingPROC MIXED or PROC GLM procedures.PROC MIXED, primarily how one treats missingness.PROC MIXED procedure to the mmrm package in the following attributes:Both languages have online documentation of the technical details of the estimation and degrees of freedom methods and the different covariance structures available.
{mmrm}
PROC MIXED
mmrm are transparent, compared to PROC MIXED.testthat framework with covr to communicate the testing coverage.Note
The integration tests in mmrm are set to a tolerance of 10e^-3 when compared to SAS outputs.
| Method | {mmrm} |
PROC MIXED |
|---|---|---|
| ML | X | X |
| REML | X | X |
Tip
For users that need more structures, mmrm is easily extensible - let us know via feature requests in the GitHub repository.
| Covariance structures | {mmrm} |
PROC MIXED |
|---|---|---|
| Unstructured (Unweighted/Weighted) | X/X | X/X |
| Toeplitz (hetero/homo) | X/X | X/X |
| Compound symmetry (hetero/homo) | X/X | X/X |
| Auto-regressive (hetero/homo) | X/X | X/X |
| Ante-dependence (hetero/homo) | X/X | X |
| Spatial exponential | X | X |
| Method | {mmrm} |
PROC MIXED |
|---|---|---|
| Contain | X* | X |
| Between/Within | X* | X |
| Residual | X* | X |
| Satterthwaite | X | X |
| Kenward-Roger | X | X |
| Kenward-Roger (Linear)** | X | X |
*Available through the emmeans package.
**This is not identical to the KR(Lin) in PROC MIXED
Contrasts and least square means estimates are available in mmrm using:
mmrm::df_1d, mmrm::df_mdemmeansemmeans (pairs method)mmrm to emmeansPROC MIXED and mmrm do not adjust for multiplicity, whereas emmeans does.mmrm::mmrm with nlme::gls, lme4::lmer, glmmTMB::glmmTMBmmrm has faster convergence time
FEV dataset as an example, mmrm took ~50 ms, while lmer ~200 ms, gls and glmmTMB >600 msmmrm and gls estimates have smaller differences from SAS PROC MIXED estimatesmmrm and gls are more resilient to missingnessmmrmcovariance, different covariance estimators (empirical, empirical Jackknife, empirical bias-reduced), predict method, etcmmrm for you! And try it out :-)

