Learn R Programming

⚠️There's a newer version (0.3.16) of this package.Take me there.

mmrm (version 0.3.15)

Mixed Models for Repeated Measures

Description

Mixed models for repeated measures (MMRM) are a popular choice for analyzing longitudinal continuous outcomes in randomized clinical trials and beyond; see Cnaan, Laird and Slasor (1997) for a tutorial and Mallinckrodt, Lane, Schnell, Peng and Mancuso (2008) for a review. This package implements MMRM based on the marginal linear model without random effects using Template Model Builder ('TMB') which enables fast and robust model fitting. Users can specify a variety of covariance matrices, weight observations, fit models with restricted or standard maximum likelihood inference, perform hypothesis testing with Satterthwaite or Kenward-Roger adjustment, and extract least square means estimates by using 'emmeans'.

Copy Link

Version

Install

install.packages('mmrm')

Monthly Downloads

6,381

Version

0.3.15

License

Apache License 2.0

Maintainer

Daniel Sabanes Bove

Last Published

June 10th, 2025

Functions in mmrm (0.3.15)

h_add_terms

Add Formula Terms with Character
fit_single_optimizer

Fitting an MMRM with Single Optimizer
fit_mmrm

Low-Level Fitting Function for MMRM
flat_expr

Flatten Expressions for Non-standard Evaluation
h_add_covariance_terms

Add Individual Covariance Variables As Terms to Formula
format.cov_struct

Format Covariance Structure Object
fev_data

Example Data on FEV1
fill_names

Complete character Vector Names From Values
formula_rhs

Extract Right-Hand-Side (rhs) from Formula
format_symbols

Format Symbol Objects
h_confirm_large_levels

Ask for Confirmation on Large Visit Levels
h_coef_table

Coefficients Table for MMRM Fit
h_default_value

Default Value on NULL Return default value when first argument is NULL.
h_df_1d_sat

Calculation of Satterthwaite Degrees of Freedom for One-Dimensional Contrast
h_df_1d_kr

Calculation of Kenward-Roger Degrees of Freedom for One-Dimensional Contrast
h_df_md_bw

Calculation of Between-Within Degrees of Freedom for Multi-Dimensional Contrast
h_df_1d_res

Calculation of Residual Degrees of Freedom for One-Dimensional Contrast
h_df_1d_sat_empirical

Helper for Calculation of Satterthwaite with Empirical Covariance Matrix
h_df_1d_bw

Calculation of Between-Within Degrees of Freedom for One-Dimensional Contrast
h_df_bw_calc

Calculation of Between-Within Degrees of Freedom
h_df_md_from_1d

Creating F-Statistic Results from One-Dimensional Contrast
h_construct_model_frame_inputs

Construction of Model Frame Formula and Data Inputs
h_drop_levels

Drop Levels from Dataset
h_df_min_bw

Assign Minimum Degrees of Freedom Given Involved Coefficients
h_df_md_kr

Calculation of Kenward-Roger Degrees of Freedom for Multi-Dimensional Contrast
h_df_md_sat

Calculation of Satterthwaite Degrees of Freedom for Multi-Dimensional Contrast
h_drop_covariance_terms

Drop Formula Terms used for Covariance Structure Definition
h_df_to_tibble

Coerce a Data Frame to a tibble
h_df_md_res

Calculation of Residual Degrees of Freedom for Multi-Dimensional Contrast
h_extra_levels

Check if a Factor Should Drop Levels
h_first_contain_categorical

Check if the Effect is the First Categorical Effect
h_extract_covariance_terms

Extract Formula Terms used for Covariance Structure Definition
h_get_contrast

Obtain Contrast for Specified Effect
h_get_sim_per_subj

Get simulated values by patient.
h_get_cov_default

Obtain Default Covariance Method
h_get_theta_from_cov

Obtain Theta from Covariance Matrix
h_get_kr_comp

Obtain Kenward-Roger Adjustment Components
h_get_optimizers

Obtain Optimizer according to Optimizer String Value
h_get_index

Test if the First Vector is Subset of the Second Vector
h_get_prediction_variance

Get Prediction Variance
h_print_cov

Printing MMRM Covariance Type
h_print_aic_list

Printing AIC and other Model Fit Criteria
h_optimizer_fun

Obtain Optimizer Function with Character
h_quad_form

Quadratic Form Calculations
h_mmrm_tmb_parameters

Start Parameters for TMB Fit
h_md_denom_df

Calculating Denominator Degrees of Freedom for the Multi-Dimensional Case
h_mmrm_tmb_check_conv

Checking the TMB Optimization Result
h_get_prediction

Get Prediction
h_jac_list

Obtain List of Jacobian Matrix Entries for Covariance Matrix
h_gradient

Computation of a Gradient Given Jacobian and Contrast Vector
h_get_na_action

Obtain na.action as Function
h_mmrm_tmb_extract_cov

Extract covariance matrix from TMB report and input data
h_get_empirical

Obtain Empirical/Jackknife/Bias-Reduced Covariance
h_kr_df

Obtain the Adjusted Kenward-Roger degrees of freedom
h_print_call

Printing MMRM Function Call
h_partial_fun_args

Create Partial Functions
h_mmrm_tmb_formula_parts

Processing the Formula for TMB Fit
h_mmrm_tmb_data

Data for TMB Fit
h_mmrm_tmb_assert_start

Asserting Sane Start Values for TMB Fit
h_newdata_add_pred

Add Prediction Results to New Data
h_register_s3

Register S3 Method Register S3 method to a generic.
h_obtain_lvls

Obtain Levels Prior and Posterior
h_residuals_normalized

Calculate normalized residuals
h_split_control

Split Control List
h_record_all_output

Capture all Output
h_residuals_response

Calculate response residuals.
h_test_1d

Creating T-Statistic Test Results For One-Dimensional Contrast
h_tbl_confint_terms

Extract tibble with Confidence Intervals and Term Names
h_mmrm_tmb_fit

Build TMB Fit Result List
h_summarize_all_fits

Summarizing List of Fits
h_residuals_pearson

Calculate Pearson Residuals
h_within_or_between

Determine Within or Between for each Design Matrix Column
h_tmb_version_sufficient

Predicate if the TMB Version Used to Compile the Package is Sufficient
h_reconcile_cov_struct

Reconcile Possible Covariance Structure Inputs
h_tr

Trace of a Matrix
is_infix

Test Whether a Symbol is an Infix Operator
h_var_adj

Obtain the Adjusted Covariance Matrix
h_tmb_warn_non_deterministic

Warn if TMB is Configured to Use Non-Deterministic Hash for Tape Optimizer
h_valid_formula

Validate mmrm Formula
h_warn_na_action

Warn on na.action
h_test_md

Creating F-Statistic Test Results For Multi-Dimensional Contrast
mmrm_control

Control Parameters for Fitting an MMRM
print.cov_struct

Print a Covariance Structure Object
mmrm

Fit an MMRM
position_symbol

Search For the Position of a Symbol
mmrm-package

mmrm Package
mmrm_tidiers

Tidying Methods for mmrm Objects
refit_multiple_optimizers

Refitting MMRM with Multiple Optimizers
parsnip_add_mmrm

Register mmrm For Use With tidymodels
mmrm_tmb_methods

Methods for mmrm_tmb Objects
tmb_cov_type

Produce A Covariance Identifier Passing to TMB
mmrm_methods

Methods for mmrm Objects
reexports

Objects exported from other packages
std_start

Standard Starting Value
validate_cov_struct

Validate Covariance Structure Data
register_on_load

Helper Function for Registering Functionality With Suggests Packages
cov_type_abbr

Retrieve Associated Abbreviated Covariance Structure Type Name
as.cov_struct

Coerce into a Covariance Structure Definition
cov_struct

Define a Covariance Structure
component

Component Access for mmrm_tmb Objects
df_1d

Calculation of Degrees of Freedom for One-Dimensional Contrast
df_md

Calculation of Degrees of Freedom for Multi-Dimensional Contrast
covariance_types

Covariance Types
emp_start

Empirical Starting Value
emmeans_support

Support for emmeans
COV_TYPES

Covariance Type Database
bcva_data

Example Data on BCVA
drop_elements

Drop Items from an Indexible
cached_mmrm_results

Cache Data for mmrm Model Comparison
cov_type_name

Retrieve Associated Full Covariance Structure Type Name
check_package_version

Check Suggested Dependency Against Version Requirements
Anova.mmrm

Conduct type II/III hypothesis testing on the MMRM fit results.
emit_tidymodels_register_msg

Format a Message to Emit When Tidymodels is Loaded
car_add_mmrm

Register mmrm For Use With car::Anova