enw_stan_to_r | R Documentation |
epinowcast
stan functions in RThis 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.
enw_stan_to_r(
files = list.files(include),
include = system.file("stan", "functions", package = "epinowcast"),
global = TRUE,
verbose = TRUE,
...
)
files |
A character vector specifying the names of Stan files to be
exposed. These must be in the |
include |
A character string specifying the directory containing Stan
files. Defaults to the 'stan/functions' directory of the |
global |
A logical value indicating whether to expose the functions
globally. Defaults to |
verbose |
Logical, defaults to |
... |
Additional arguments passed to enw_model. |
An object of class CmdStanModel
with functions from the model
exposed for use in R.
Functions used to help convert models into the format required for stan
enw_formula_as_data_list()
,
enw_get_cache()
,
enw_model()
,
enw_pathfinder()
,
enw_priors_as_data_list()
,
enw_replace_priors()
,
enw_sample()
,
enw_set_cache()
,
enw_unset_cache()
,
remove_profiling()
,
write_stan_files_no_profile()
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.