Installation


epidemia requires R v3.5.0 or above. The latest version of R can be downloaded here.

Models are fit with Stan through the cmdstanr interface. Unlike the previous rstan-based versions of the package, the Stan models are not compiled when epidemia is installed. Instead they are compiled the first time they are used and then cached, so the one-off C++ compilation happens at run time rather than at install time.

1. Install cmdstanr and CmdStan

# install cmdstanr
install.packages(
  "cmdstanr",
  repos = c("https://stan-dev.r-universe.dev", getOption("repos"))
)

# install CmdStan itself (requires a working C++ toolchain: on macOS the
# Xcode command line tools, on Windows RTools, on Linux gcc/g++)
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan(cores = parallel::detectCores())

See the cmdstanr getting-started guide if you run into toolchain issues.

2. Install epidemia

# install.packages("remotes")
remotes::install_github("mlgh-sg/epidemia2")

will install the latest development version of epidemia.

3. (Optional) Precompile the Stan models

The Stan programs are compiled automatically the first time epim() is called. To move that one-off cost to a convenient time (for example straight after installation, or after upgrading CmdStan), run:

epidemia::compile_epidemia()

Vignettes are not currently included in the package because they are computationally demanding, and are best viewed online.