Skip to contents

Check 🛠 Docs 📚 Code Coverage 📔

GitHub forksGitHub repo stars

GitHub commit activityGitHub contributorsGitHub last commitGitHub pull requestsGitHub repo sizeGitHub language countProject Status: Active – The project has reached a stable, usable state and is being actively developed. Current Version Open Issues


tern.mmrm provides an interface for mixed model repeated measures (MMRM) within the tern framework to produce commonly used tables (using rtables) and graphs. It builds on the R-package mmrm for the actual MMRM calculations.

When to use this package

If you would like to use the tern framework for tabulation and graphs, then this package is ideal for your MMRM fits. However if you use another reporting framework then it will be better to directly use mmrm and perform the tabulation and plots differently.

Main Features

  • Fitting of MMRM models to continuous longitudinal data collected over several time points (called visits) and optionally treatment arms.
  • Tabulation and plots of least square means per visit and treatment arm.
  • Tabulation of model diagnostics (e.g. BIC).
  • Diagnostic graphs (e.g. Q-Q plot of residuals).
  • Tabulation and plots of the covariance matrix estimate.
  • Subgroup specific refitting of the MMRM model and resulting forest plot.



It is recommended that you create and use a GitHub PAT to install the latest version of this package. Once you have the PAT, run the following:

Sys.setenv(GITHUB_PAT = "your_access_token_here")
if (!require("remotes")) install.packages("remotes")

NEST distribution

A stable release of all NEST packages is also available here.

Getting started

You can get started by trying out the example:

fit <- fit_mmrm(
  vars = list(
    response = "FEV1",
    covariates = c("RACE", "SEX"),
    id = "USUBJID",
    arm = "ARMCD",
    visit = "AVISIT"
  data = mmrm_test_data,
  cor_struct = "unstructured",
  weights_emmeans = "equal",
  averages_emmeans = list(
    "VIS1+2" = c("VIS1", "VIS2")

This specifies an MMRM with the FEV1 outcome and the RACE and SEX covariates for subjects identified by USUBJID and treatment arm ARMCD observed over time points identified by AVISIT in the mmrm_test_data data set. An unstructured covariance matrix is assumed. Note that only restricted maximum likelihood (REML) can be used. The least square means assume equal weights for factor combinations, and in addition to the single visit specific results an average across visits VIS1 and VIS2 will be computed.


For a more detailed introduction to all of the features of this package, look at the introduction vignette:




Stargazers repo roster for @insightsengineering/tern.mmrm Forkers repo roster for @insightsengineering/tern.mmrm

Over time

Stargazers over time