MCSimMod: An R Package for Working with Ordinary Differential Equation Models Encoded in the MCSim Model Specification Language
In this paper, we present the R package MCSimMod for working with ordinary differential equation (ODE) models. R is a free and open-source programming language and environment popular among statisticians and scientists because of its data analysis and graphics generation capabilities. Working within the interactive R environment, users can quickly and easily obtain results for many simple or standard types statistical or graphical analyses, but unfortunately the complex calculations associated with performing ODE model simulations are performed relatively slowly for models encoded in R because R is an interpreted language. MCSim, which is another free and open-source software tool, was designed for the more specialized purposes of implementing and calibrating mathematical models. By taking advantage of the compiled language C, MCSimMod performs ODE model simulations relatively quickly. Using R and MCSim together allows one to define ODE models in a relatively simple language, translate and compile the models, and perform model simulations rapidly from within the R environment. However, installing R, MCSim, and other required software tools and ensuring that they work together properly can be an onerous process. To solve this problem, we developed the R package MCSimMod, which can be installed easily in the R programming environment. Notably, use of the package does not require installation of the MCSim software. To demonstrate the utility of MCSimMod, in this paper we illustrate how to perform various essential modeling tasks using several example ODE models. We show how to encode ODE models in the MCSim model specification language, set parameter values and initial conditions for the models, perform model simulations, introduce time-varying input parameters, and incorporate discrete events into model simulations. The MCSimMod package grants R users access to an efficient and easy-to-use set of tools for building and performing simulations with ODE models, and makes it easy for users to share their ODE models and modeling analyses with others. The views expressed in this manuscript are those of the authors and do not necessarily represent the views or policies of the U.S. Environmental Protection Agency.