Generates credible intervals on titres and infection histories from an MCMC chain output.

get_titre_predictions(
  chain,
  infection_histories,
  titre_dat,
  individuals,
  antigenic_map = NULL,
  strain_isolation_times = NULL,
  par_tab,
  nsamp = 100,
  add_residuals = FALSE,
  mu_indices = NULL,
  measurement_indices_by_time = NULL,
  for_res_plot = FALSE,
  expand_titredat = FALSE,
  titre_before_infection = FALSE,
  titres_for_regression = FALSE
)

Arguments

chain

the full MCMC chain to generate titre trajectories from

infection_histories

the MCMC chain for infection histories

titre_dat

the data frame of titre data

individuals

the subset of individuals to generate credible intervals for

antigenic_map

(optional) a data frame of antigenic x and y coordinates. Must have column names: x_coord; y_coord; inf_times. See example_antigenic_map

strain_isolation_times

(optional) if no antigenic map is specified, this argument gives the vector of times at which individuals can be infected

par_tab

the table controlling the parameters in the MCMC chain

nsamp

number of samples to take from posterior

add_residuals

if true, returns an extra output summarising residuals between the model prediction and data

mu_indices

vector of integers. for random effects on boosting parameter, mu. If random mus are included in the parameter table, this vector specifies which mu to use for each circulation year. For example, if years 1970-1976 have unique boosting, then mu_indices should be c(1,2,3,4,5,6). If every 3 year block shares has a unique boosting parameter, then this should be c(1,1,1,2,2,2)

measurement_indices_by_time

default NULL, optional vector giving the index of `measurement_bias` that each strain uses the measurement shift from from. eg. if there's 6 circulation years and 3 strain clusters

for_res_plot

TRUE/FALSE value. If using the output of this for plotting of residuals, returns the actual data points rather than summary statistics

expand_titredat

TRUE/FALSE value. If TRUE, solves titre predictions for all possible infection times. If left FALSE, then only solves for the infections times at which a titre against the circulating virus was measured in titre_dat.

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.

Value

a list with the titre predictions (95

Examples

if (FALSE) { data(example_theta_chain) data(example_inf_chain) data(example_titre_dat) data(example_antigenic_map) data(example_par_tab) y <- get_titre_predictions(example_theta_chain, example_inf_chain, example_titre_dat, unique(example_titre_dat$individual), example_antigenic_map, example_par_tab,expand_titredat = FALSE) }