R/plot_infection_histories.R
plot_infection_history_posteriors.RdPlots and calculates summary statistics from the infection-history MCMC chain.
plot_infection_history_posteriors(
inf_chain,
possible_exposure_times,
n_alive,
known_ar = NULL,
known_infection_history = NULL,
burnin = 0,
samples = 100,
pad_chain = FALSE
)the infection-history chain returned by load_mcmc_chains, in long format
vector of possible exposure times, in the same order as the infection-history columns
data frame giving the number of people alive for each exposure time and population group. This is used to calculate attack rates.
optional data frame of known attack rates, with `j`, `population_group`, and `AR` columns
optional matrix or data frame of known infection histories, with individuals in rows and possible exposure times in columns
if not already discarded, discards rows with `samp_no <= burnin`
number of MCMC samples to use for the plots
if TRUE, adds zero-valued entries for infection events that are absent from the sparse chain
A list containing trace plots by time and individual, a plot of the number of infections per individual, and the posterior estimates returned by calculate_infection_history_statistics.
Other infection_history_plots:
calculate_infection_history_statistics(),
plot_antibody_data(),
plot_antibody_predictions(),
plot_cumulative_infection_histories(),
plot_estimated_antibody_model(),
plot_individual_number_infections(),
plot_infection_history_chains_indiv(),
plot_infection_history_chains_time(),
plot_model_fits(),
plot_total_number_infections()
if (FALSE) { # \dontrun{
## Load in example data
data(example_inf_chain)
data(example_antigenic_map)
data(example_antibody_data)
possible_exposure_times <- example_antigenic_map$inf_times
## Setup known attack rates
n_alive <- get_n_alive(example_antibody_data, possible_exposure_times)
n_infs <- colSums(example_inf_hist)
known_ar <- n_infs/n_alive
known_ar <- data.frame("j"=possible_exposure_times,"AR"=known_ar,"population_group"=1)
## Setup known infection histories
known_inf_hist <- data.frame(example_inf_hist)
colnames(known_inf_hist) <- possible_exposure_times
n_alive_group <- get_n_alive_group(example_antibody_data, possible_exposure_times,melt_data = TRUE)
n_alive_group$j <- possible_exposure_times[n_alive_group$j]
all_plots <- plot_infection_history_posteriors(example_inf_chain, possible_exposure_times, n_alive_group,
known_ar=known_ar,known_infection_history = known_inf_hist,
samples=100)
} # }