enw_replace_priors | R Documentation |
This function is used internally by epinowcast to replace
default model priors with users specified ones (restricted to
normal priors with specified mean and standard deviations). A common
use would be extracting the posterior from a previous epinowcast()
run (using summary(nowcast, type = fit)
) and using this a prior.
enw_replace_priors(priors, custom_priors)
priors |
A |
custom_priors |
A |
A data.table of prior definitions (variable, mean and sd).
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_sample()
,
enw_set_cache()
,
enw_stan_to_r()
,
enw_unset_cache()
,
remove_profiling()
,
write_stan_files_no_profile()
# Update priors from a data.frame
priors <- data.frame(variable = c("x", "y"), mean = c(1, 2), sd = c(1, 2))
custom_priors <- data.frame(variable = "x[1]", mean = 10, sd = 2)
enw_replace_priors(priors, custom_priors)
# Update priors from a previous model fit
default_priors <- enw_reference(
distribution = "lognormal",
data = enw_example("preprocessed"),
)$priors
print(default_priors)
fit_priors <- summary(
enw_example("nowcast"), type = "fit",
variables = c("refp_mean_int", "refp_sd_int", "sqrt_phi")
)
fit_priors
enw_replace_priors(default_priors, fit_priors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.