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.
mmrm is an R package, and the following sections describe all files/folders that are contained in this package as well as the repository.
dataThe data/ folder is where mmrm example data sets is stored. See the documentation for fev_data and bcva_data for details.
data-rawThe data-raw/ folder contains source code to produce simulated example data sets. Currently it contains bcva_data.R (and its associated helper file) producing the bcva_data data set, and the cached results for comparing mmrm and other implementations.
designThe design/ folder is where design documents, prototype scripts and SAS code for comparisons are stored. When we have a new idea for a specific implementations, we can add our design doc including prototype implementations in an Rmd file in this folder.
Note that this folder is not part of the actual R package but only part of the git repository. Different folders contain R scripts and Rmd files for different topics, for example:
SASThe design/SAS/ folder contains programs to run MMRM models in SAS and the corresponding SAS outputs. The results will be used for integration tests (see integration tests).
TMBThe design/TMB/ folder is where prototypes of the first mmrm implementations with TMB are stored.
instFiles in the inst/ folder will be kept after installation of the R package.
jss.csl is specifying the Journal of Statistical Software citation style used by Rdpack references.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.manThe man/ folder contains all function documentation generated by roxygen2. Please do not edit any file in this folder, otherwise you may run into problems.
NAMESPACESince we use roxygen2 also the NAMESPACE file is automatically generated and usually does not need to be edited manually.
Note that there can be exceptions, e.g. when removing a previously exported function from the package, in which case a manual deletion of the corresponding entry might be necessary to unblock roxygen2.
NEWS.mdThis file lists the user facing changes (new features, bug fixes, etc.) and should be updated during the development and cleaned before each release. It is important for the user experience to understand the changes between the releases.
RThis folder contains all the source code written in R, just like every other R packages. Please refer to the documentation page for details of the user facing API.
READMEWe use the Rmd file README.Rmd and knit this to the corresponding md file. This file specifies the landing page on the pkgdown website and the GitHub repository and should hence be nice, succinct and clean.
simulationsThis folder contains simulation scripts and results to compare mmrm with other software or modifications in mmrm. Please refer to the README files in the subfolders for details.
srcThis folder includes all the source code written in C++, either using Rcpp or TMB frameworks.
chol_cache.hThis file contains classes for caching the Cholesky factorizations efficiently.
covariance.hThis 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, see the model fitting algorithm vignette.
For more about covariance structures, see the covariance structures vignette.
derivatives.hThis file contains classes to enable automatic differentiation calculation which are important for the coefficient covariance matrix calculations and Kenward-Roger and Satterthwaite degrees of freedom calculations.
empirical.cppThis file implements the coefficient covariance matrix calculations.
exports.cppThis file contains the Rcpp interfaces to the coefficient covariance matrix, Kenward-Roger, Jacobian and prediction calculations.
jacobian.cppThis file implements the Jacobian calculations which are needed for the Satterthwaite degrees of freedom.
kr_comp.cppThis file implements the P, Q and R matrix calculations which are needed for the Kenward-Roger degrees of freedom.
MakevarsThis file specifies additional flags used in the source code compilation. We ask TMB to use the TMB automatic differentiation framework (instead of the default CppAD framework) to be more efficient, and disable useless warnings from the Eigen library compilation.
Note that additional flags such as -Wno-ignored-attributes cannot be included here because they are compiler specific. These can instead be specified in local ~/.R/Makevars files.
mmrm.cppThis file is the core part where the likelihood is calculated. The objective function reads input from R and performs the calculations inside.
predict.cppThis file implements the prediction calculations.
Files starting with test- are tests or helper files to run tests. (It is important to also aim for high unit test coverage of the source code.)
tmb.cpp and tmb_includes.hThese two files includes the TMB module.
utils.hThis files includes utilities that used internally.
testsThe tests/ folder includes all the unit tests for the R functions, using the testthat package.
vignettesThe vignettes/ folder includes Rmd documentation files 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.
There are other files that can be helpful in package development and are used in mmrm.
_pkgdown.ymlThis 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.
.gitignoreThis file will specify untracked files/file patterns that git should ignore.
.lintrThis 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.
.pre-commit-config.yamlThis 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.
.RbuildignoreThis file specifies which files and folders in the repository should not be included when building the R package.
Please note that it is important to know that these are regular expressions. Hence, when we want to specify an exact file name we need to use e.g. the ^cache$ format, just using cache instead could match additional files or folders with cache being part of the name. This can lead to problems.