As mmrm package is built on TMB with complex structure, it might be hard for new developers to onboard. To make it easier for new developers to join, this documentation is created.

Package Structures

mmrm is an R package, and the following sections describe all files/folders that are contained in this package.


The data/ folder is where mmrm internal data is stored. See the fev_data documentation and the introduction vignette for details.


The design/ folder is where the prototypes and SAS implementations stored. When we have a new idea for a specific implementations, we can add our prototypes in a Rmarkdown file to this folder. We can then push these prototypes to github and collect feedback on the proposed ideas. Currently we only have SAS and TMB folders.


The design/SAS/ folder contains the programs to run MMRM models and corresponding SAS outputs. The results will be used for integration tests. See integration tests.


The design/TMB/ folder is where prototypes of mmrm implementations stored. You can add your ideas/prototypes here.


Files in the inst/ folder will be kept after installation.

  • REFERENCES.bib keeps a list of all referenced literature.
  • WORDLIST is kept up-to-date for all non-English words, allowing the package to pass a spell-checker.


The man/ folder contains all function documentation generated by Roxygen. Please do not edit any file in this folder otherwise you may run into issues.


This folder contains all the source code written in R, just like every other R packages. Please refer to the documentation page for details.


src folders includes all the source code written in C++. Files starting with test- are tests.


This file includes the implementations of covariance structures with suitable parameterization, and the calculation of lower triangular part of Cholesky factorization of the covariance matrix.

For more about the implementations and why Cholesky factorization is needed, visit mmrm details vignette.

For more about covariance structures, visit covariance structures vignette.


This file includes the initialization of R and C++ communication.


This file is the core part where the likelihood is calculated. The objective function reads input from R and do the calculations inside.


This files includes utilities that used internally.

tmb.cpp and tmb_includes.h

These two files includes the TMB module.

test- files

All files starting with test- are unit tests for the C++ codes.


The tests/ folder includes all the unit tests for the R functions, using the testthat package.


The vignettes/ folder includes Rmarkdown-based documentation to helps the user understand more about the usage, detail, etc. These vignettes are rendered into .html files which are deployed on the package website.

other files

There are other files that can be helpful in package development.


This file will specify untracked files/file patterns that git should ignore.


This file serves as configuration for lintr to do the static code analysis. Please install lintr package in your developing system to enable the analysis. It will provide you information about errors, style issues, etc.

For more, visit lintr documentation.


This file includes the configurations that we use for pre-commit. pre-commit is a tool that help us identify simple issues before we submit our code. For more, visit pre-commit documentation.


This file is the configuration file for our pkgdown-based website. pkgdown is used to covert our package documentation (man/, vignettes/) into our package website.

For more, visit pkgdown documentation.


This file is the configuration file for staged.dependencies. staged.dependencies is used to ensure that dependencies are consistent across multiple repositories which are being developing at the same time.

For more, visit staged.dependencies documentation.