Given outputs from an MCMC run and the data used for fitting, generates an NxM matrix of plots where N is the number of individuals to be plotted and M is the range of sampling times. Where data are available, plots the observed titres and model predicted trajectories

plot_infection_histories(
  chain,
  infection_histories,
  titre_dat,
  individuals,
  antigenic_map = NULL,
  strain_isolation_times = NULL,
  par_tab,
  nsamp = 100,
  mu_indices = NULL,
  measurement_indices_by_time = NULL
)

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

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

Value

a ggplot2 object

See also

Examples

if (FALSE) { data(example_theta_chain) data(example_inf_chain) data(example_titre_dat) data(example_antigenic_map) data(example_par_tab) model_fit_plot <- plot_infection_histories(example_theta_chain, example_inf_chain, example_titre_dat, 1:10, example_antigenic_map, example_par_tab) }