Skip to contents

This function facilitates the exposure of Stan functions from the epinowcast package in R. It utilizes the expose_functions() method of cmdstanr::CmdStanModel or this purpose. This function is useful for developers and contributors to the epinowcast package, as well as for users interested in exploring and prototyping with model functionalities.


  files = list.files(include),
  include = system.file("stan", "functions", package = "epinowcast"),
  global = TRUE,
  verbose = TRUE,



A character vector specifying the names of Stan files to be exposed. These must be in the include directory. Defaults to all Stan files in the include directory. Note that the following files contain overloaded functions and cannot be exposed: "delay_lpmf.stan", "allocate_observed_obs.stan", "obs_lpmf.stan", and "effects_priors_lp.stan".


A character string specifying the directory containing Stan files. Defaults to the 'stan/functions' directory of the epinowcast() package.


A logical value indicating whether to expose the functions globally. Defaults to TRUE. Passed to the expose_functions() method of cmdstanr::CmdStanModel.


Logical, defaults to TRUE. Should verbose messages be shown.


Additional arguments passed to enw_model.


An object of class CmdStanModel with functions from the model exposed for use in R.

See also


if (FALSE) { # interactive()
# Compile functions in stan/functions/hazard.stan
stan_functions <- enw_stan_to_r("hazard.stan")
# These functions can now be used in R
stan_functions$functions$prob_to_hazard(c(0.5, 0.1, 0.1))
# or exposed globally and used directly
prob_to_hazard(c(0.5, 0.1, 0.1))