create_posterior_func | R Documentation |
Takes all of the input data/parameters and returns a function pointer. This function finds the posterior for a given set of input parameters (theta) and infection histories without needing to pass the data set back and forth. No example is provided for function_type=2, as this should only be called within run_MCMC
create_posterior_func(
par_tab,
titre_dat,
antigenic_map = NULL,
strain_isolation_times = NULL,
version = 1,
solve_likelihood = TRUE,
age_mask = NULL,
measurement_indices_by_time = NULL,
mu_indices = NULL,
n_alive = NULL,
function_type = 1,
titre_before_infection = FALSE,
data_type = 1,
...
)
par_tab |
the parameter table controlling information such as bounds, initial values etc. See |
titre_dat |
the data frame of data to be fitted. Must have columns: group (index of group); individual (integer ID of individual); samples (numeric time of sample taken); virus (numeric time of when the virus was circulating); titre (integer of titre value against the given virus at that sampling time). See |
antigenic_map |
(optional) a data frame of antigenic x and y coordinates. Must have column names: x_coord; y_coord; inf_times. See |
strain_isolation_times |
(optional) if no antigenic map is specified, this argument gives the vector of times at which individuals can be infected |
version |
which infection history assumption version to use? See |
solve_likelihood |
usually set to TRUE. If FALSE, does not solve the likelihood and instead just samples/solves based on the model prior |
age_mask |
see |
measurement_indices_by_time |
if not NULL, then use these indices to specify which measurement bias parameter index corresponds to which time |
mu_indices |
if not NULL, then use these indices to specify which boosting parameter index corresponds to which time |
n_alive |
if not NULL, uses this as the number alive in a given year rather than calculating from the ages. This is needed if the number of alive individuals is known, but individual birth dates are not |
function_type |
integer specifying which version of this function to use. Specify 1 to give a posterior solving function; 2 to give the gibbs sampler for infection history proposals; otherwise just solves the titre model and returns predicted titres. NOTE that this is not the same as the attack rate prior argument, |
titre_before_infection |
TRUE/FALSE value. If TRUE, solves titre predictions, but gives the predicted titre at a given time point BEFORE any infection during that time occurs. |
data_type |
integer, currently accepting 1 or 2. Set to 1 for discretized, bounded data, or 2 for continuous, bounded data. Note that with 2, MIN_TITRE must be set. |
... |
other arguments to pass to the posterior solving function |
a single function pointer that takes only pars and infection_histories as unnamed arguments. This function goes on to return a vector of posterior values for each individual
## Not run:
data(example_par_tab)
data(example_titre_dat)
data(example_antigenic_map)
data(example_inf_hist)
## Simple model solving code. Output matches entries of example_titre_dat
model_func <- create_posterior_func(example_par_tab, example_titre_dat, example_antigenic_map, function_type = 3)
y <- model_func(example_par_tab$values, example_inf_hist)
## Solve likelihood
par_tab <- example_par_tab[example_par_tab$names != "phi",]
likelihood_func <- create_posterior_func(par_tab, example_titre_dat, example_antigenic_map, function_type = 1, version = 2)
liks <- likelihood_func(par_tab$values, example_inf_hist)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.