Skip to content

mrgsolve Installation

Kyle Baron edited this page Nov 1, 2016 · 41 revisions

Prerequisites

  • R: https://cran.r-project.org/
    • Currently R >= 3.1.2 is required
    • IMPORTANT Install R in a location such that no spaces are in the path to R executable; this is usually not an issue on unix type machines (linux or MacOSX) but can cause problems on windows. This means, do not install R in c:\Program Files; you won't be able to install packages from source or compile your model. For reference see this answer on SO.
  • Seriously consider running in Rstudio if possible. This is not required but is recommended.
  • Compilers: C++ and gfortran (see the Compilers section below)

Compilers

There is a separate wiki page for information on compilers required to use mrgsolve. Please visit that page and make sure the compiler is properly installed before proceeding to the next steps.

Obtaining mrgsolve

  • Get the latest release here
  • Get the development version with the devtools package:
library(devtools)
devtools::install_github("metrumresearchgroup/mrgsolve", subdir="rdev", type="source")

Dependencies

Installing mrgsolve via install_github will also install required dependencies. It is best practice to use the most recent version of mrgsolve and recent versions of all depencencies. The following section will discuss what depencencies are required.

Installing packages in R

See https://cran.r-project.org/web/packages/ or R> help("INSTALL") or R> help("install.packages") for help.

Required packages

The following required packages must be installed before installing mrgsolve:

  1. BH
  2. Rcpp
  3. RcppArmadillo
  4. dplyr

All of these required packages are available on CRAN. mrgsolve imports from dplyr and links to BH, Rcpp, and RcppArmadillo. For the purposes of this document, they will be referred to as dependencies insofar as they are required to install and run mrgsolve. But note well that they are not technically dependencies the way R uses that term. Only the package namespaces and not the packages themselves will be loaded when mrgsolve is loaded.

There are minimum version numbers for each dependency. R will issue an error during mrgsolve installation if insufficient versions of dependencies are currently installed. See the DESCRIPTION file in the .tar.gz archive for minimum dependency version numbers. Also, note that each required package with respect to mrgsolve may have requirements of their own. Install all required packages and their requirements as well prior to installing mrgsolve.

NOTE: Rcpp and RcppArmadillo must be installed from source packages (e.g. install.packages("Rcpp", type="source")). Also, whenever new versions of Rcpp, RcppArmadillo or mrgsolve are installed, it is good practice to re-install / re-compile all three of these packages (see Compilers below).

Suggested packages

These packages may be needed to perform certain tasks in mrgsolve:

  1. lattice
  2. testthat
  3. XML

R users usually already have lattice installed on their system. testthat and XML are only required for a few tasks and the majority of the simulation work can be done without them.

Example installation code

Setup

Point the installation to your favorite CRAN repository:

repos <- "http://cran.us.r-project.org"

Install dependencies

This little function will ensure that source packages are installed from CRAN; do NOT install binary packages.

install <- function(x,...) install.packages(x,type="source",repos=repos,...)

Install dependencies:

install("Rcpp")
install("RcppArmadillo")
install("BH")
install("dplyr")

Install mrgsolve

To install version 0.7.1 from the source tarball:

Check that you can find the tarball. For example:

file.exists("mrgsolve_0.7.1.tar.gz")

Use the name of the tarball that you downloaded and the path to that file. If this doesn't come back TRUE, modify the command (file name or path) untill R can find it.

Install:

install.packages("mrgsolve_0.7.1.tar.gz", repos=NULL, type="source")

Note that repos is set to NULL and we are telling R that the package is source, not binary. Also, we assume that the mrgsolve_0.7.1.tar.gz file is in the current working directory (see previous check).

To install other versions of mrgsolve, use the appropriate version number in for the tarball that you are trying to install (e.g. mrgsolve_a.b.xyz.tar.gz).

Alternative: install via devtools

mrgsolve and all depencencies can be installed with this command

library(devtools)
install_github("metrumresearchgroup/mrgsolve@v0.7.1", subdir="rdev", type="source")

Test the installation

library(mrgsolve)
?mrgsolve
example("mrgsolve")

Upgrading to a new version

Users are encouraged to re-install or re-compile Rcpp and RcppArmadillo prior to upgrading to a new version of mrgsolve. To upgrade mrgsolve, simply follow the install step above.


© 2016 Metrum Research Group, LLC
www.metrumrg.com
Clone this wiki locally