plot_posteriors_infhist: Plot inferred posteriors infection histories

View source: R/plot_infection_histories.R

plot_posteriors_infhistR Documentation

Plot inferred posteriors infection histories

Description

Plots and calculates many summary statistics from the infection history MCMC chain

Usage

plot_posteriors_infhist(
  inf_chain,
  possible_exposure_times,
  n_alive,
  known_ar = NULL,
  known_infection_history = NULL,
  burnin = 0,
  samples = 100,
  pad_chain = TRUE
)

Arguments

inf_chain

the data table with infection history samples from serosolver

possible_exposure_times

vector of the epochs of potential circulation

known_ar

data frame of known attack rates, if known.

known_infection_history

data frame of known infection histories.

burnin

if not already discarded, discard burn in from chain (takes rows where samp_no > burnin)

samples

how many samples from the chain to take

pad_chain

if TRUE, pads the infection history MCMC chain with non-infection events

n_alive_group

vector with the number of people alive in each year of circulation.

Value

a list of ggplot objects and data frame of posterior estimates

See Also

Other infection_history_plots: calculate_infection_history_statistics(), plot_antibody_data(), plot_cumulative_infection_histories(), plot_individual_number_infections(), plot_infection_history_chains_indiv(), plot_infection_history_chains_time(), plot_model_fits(), plot_total_number_infections()

Examples

## Not run: 
## 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_dat = TRUE)
n_alive_group$j <- possible_exposure_times[n_alive_group$j]
all_plots <- plot_posteriors_infhist(example_inf_chain, possible_exposure_times, n_alive_group,
                                     known_ar=known_ar,known_infection_history = known_inf_hist,
                                     samples=100)

## End(Not run)

adamkucharski/serosolver documentation built on April 13, 2024, 10:24 a.m.