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.
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.
- 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.
tern.mmrm
is available on CRAN and you can install the latest released version with:
install.packages("tern.mmrm")
or you can install the latest development version directly from GitHub by running the following:
# install.packages("pak")
pak::pak("insightsengineering/tern.mmrm")
You can get started by trying out the example:
library(tern.mmrm)
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:
vignette("introduction")