View source: R/drjacoby_utils.R
drjacoby_mcmc | R Documentation |
The drjacoby mcmc sampler is very similar to [[pmcmc]] but there are a few subtle differences that meant it was easier to have a separate function for using drjacoby for the mcmc process
drjacoby_mcmc( data, n_mcmc, log_likelihood = NULL, log_prior = NULL, n_particles = 100, steps_per_day = 4, output_proposals = FALSE, n_chains = 1, squire_model = explicit_model(), pars_obs = list(phi_cases = 1, k_cases = 2, phi_death = 1, k_death = 2, exp_noise = 1e+06), pars_init = list(start_date = as.Date("2020-02-07"), R0 = 2.5, Meff = 2, Meff_pl = 3, R0_pl_shift = 0), pars_min = list(start_date = as.Date("2020-02-01"), R0 = 0, Meff = 1, Meff_pl = 2, R0_pl_shift = -2), pars_max = list(start_date = as.Date("2020-02-20"), R0 = 5, Meff = 3, Meff_pl = 4, R0_pl_shift = 5), pars_discrete = list(start_date = TRUE, R0 = FALSE, Meff = FALSE, Meff_pl = FALSE, R0_pl_shift = FALSE), reporting_fraction = 1, treated_deaths_only = FALSE, country = NULL, population = NULL, contact_matrix_set = NULL, baseline_contact_matrix = NULL, date_contact_matrix_set_change = NULL, R0_change = NULL, date_R0_change = NULL, hosp_bed_capacity = NULL, baseline_hosp_bed_capacity = NULL, date_hosp_bed_capacity_change = NULL, ICU_bed_capacity = NULL, baseline_ICU_bed_capacity = NULL, date_ICU_bed_capacity_change = NULL, date_vaccine_change = NULL, baseline_max_vaccine = NULL, max_vaccine = NULL, date_vaccine_efficacy_infection_change = NULL, baseline_vaccine_efficacy_infection = NULL, vaccine_efficacy_infection = NULL, date_vaccine_efficacy_disease_change = NULL, baseline_vaccine_efficacy_disease = NULL, vaccine_efficacy_disease = NULL, Rt_args = NULL, burnin = 0, replicates = 100, forecast = 0, drjacoby_list = list(), ... )
data |
Data to fit to. This must be constructed with
|
n_mcmc |
number of mcmc mcmc iterations to perform |
log_likelihood |
function to calculate log likelihood, must take named parameter vector as input, allow passing of implicit arguments corresponding to the main function arguments. Returns a named list, with entries: - $log_likelihood, a single numeric - $sample_state, a numeric vector corresponding to the state of a single particle, chosen at random, at the final time point for which we have data. If NULL, calculated using the function calc_loglikelihood. |
log_prior |
function to calculate log prior, must take named parameter vector as input, returns a single numeric. If NULL, uses uninformative priors which do not affect the posterior |
n_particles |
Number of particles (considered for both the PMCMC fit and sampling from posterior) |
steps_per_day |
Number of steps per day |
output_proposals |
Logical indicating whether proposed parameter jumps should be output along with results |
n_chains |
number of MCMC chains to run |
squire_model |
A squire model to use |
pars_obs |
list of parameters to use in comparison
with |
pars_init |
named list of initial inputs for parameters being sampled |
pars_min |
named list of lower reflecting boundaries for parameter proposals |
pars_max |
named list of upper reflecting boundaries for parameter proposals |
pars_discrete |
named list of logicals, indicating if proposed jump should be discrete |
reporting_fraction |
Reporting fraction. Numeric for what proportion of
the total deaths the reported deaths represent. E.g. 0.5 results in
the model calibrating to twice the deaths provided by |
treated_deaths_only |
Boolean for whether likelihood is based only on deaths that occur from healthcare systems, i.e. are treated. Default = FALSE, which uses all deaths. |
country |
Character for country beign simulated. WIll be used to
generate |
population |
Population vector (for each age group). Default = NULL,
which will cause population to be sourced from |
contact_matrix_set |
List of contact matrices to be used from the dates
provided in |
baseline_contact_matrix |
The starting contact matrix prior to any changes due to interventions or otherwise. Default = NULL, which will use the contact matrix associated with the coutnry provided. |
date_contact_matrix_set_change |
Calendar dates at which the contact matrices
set in |
R0_change |
Numeric vector for relative changes in R0. Default = NULL, i.e. no change in R0 |
date_R0_change |
Calendar dates at which R0_change occurs. Defaut = NULL, i.e. no change in R0 |
hosp_bed_capacity |
Number of hospital beds at each date specified in
|
baseline_hosp_bed_capacity |
The starting number of hospital beds before the epidemic started. Default = NULL, which will use the hospital beds data for the country provided. If no country is provided then this is 5/1000 of the population |
date_hosp_bed_capacity_change |
Calendar dates at which hospital bed
capacity changes set in |
ICU_bed_capacity |
Number of ICU beds at each date specified in
|
baseline_ICU_bed_capacity |
The starting number of ICU beds before the epidemic started. Default = NULL, which will use the hospital beds data for the country provided. If no country is provided then this is 3/100 of hospital beds |
date_ICU_bed_capacity_change |
Calendar dates at which ICU bed
capacity changes set in |
date_vaccine_change |
Date that vaccine doses per day change. Default = NULL. |
baseline_max_vaccine |
Baseline vaccine doses per day. Default = NULL |
max_vaccine |
Time varying maximum vaccine doeses per day. Default = NULL. |
date_vaccine_efficacy_infection_change |
Date that vaccine efficacy against infection changes. Default = NULL. |
baseline_vaccine_efficacy_infection |
Baseline vaccine effacy against infection. Default = NULL |
vaccine_efficacy_infection |
Time varying vaccine efficacy against infection. Default = NULL. |
date_vaccine_efficacy_disease_change |
Date that vaccine efficacy against disease changes. Default = NULL. |
baseline_vaccine_efficacy_disease |
Baseline vaccine efficacy against disease Default = NULL |
vaccine_efficacy_disease |
Time varying vaccine efficacy against infection. Default = NULL. |
Rt_args |
List of arguments to be passed to |
burnin |
number of iterations to discard from the start of MCMC run when sampling from the posterior for trajectories |
replicates |
number of trajectories (replicates) to be returned that are being sampled from the posterior probability results produced by |
forecast |
Number of days to forecast forward. Default = 0 |
drjacoby_list |
List of arguments to pass to [[drjacoby::run_mcmc]] that are not data, df_params, misc, loglike, logprior, burnin or samples |
... |
Further aguments for the model parameter function. If using the
|
Run a drjacoby mcmc sampler with the Squire model setup
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.