Plots inferred historical attack rates from the MCMC output on infection histories, with pointrange plots for per-time incidence estimates

plot_attack_rates(
  infection_histories,
  antibody_data = NULL,
  demographics = NULL,
  par_tab = NULL,
  possible_exposure_times = NULL,
  n_alive = NULL,
  pointsize = 1,
  fatten = 1,
  pad_chain = FALSE,
  prior_pars = NULL,
  plot_den = FALSE,
  plot_ribbon = FALSE,
  true_ar = NULL,
  by_group = FALSE,
  group_subset = NULL,
  plot_residuals = FALSE,
  colour_by_taken = TRUE,
  by_val = 5,
  min_time = min(possible_exposure_times),
  max_time = max(possible_exposure_times),
  settings = NULL,
  verbose = FALSE
)

Arguments

infection_histories

the MCMC chain for infection histories

antibody_data

the data frame of antibody data

demographics

optional demographic data used to assign population groups

par_tab

the model control table used when demographic groups are present

possible_exposure_times

vector of the epochs of potential infection

n_alive

optional number-alive data. If NULL, the number alive is calculated from `antibody_data` and `birth`.

pointsize

graphics option controlling point size

fatten

graphics option controlling the width of pointrange end caps

pad_chain

if TRUE, fills the infection-history data table with entries for non-infection events (0s). Set to FALSE for a faster, approximate plot.

prior_pars

if not NULL, a list of parameters for the attack rate prior, giving the assumed prior_version along with infection_model_prior_shape1 and infection_model_prior_shape2

plot_den

if TRUE, produces a violin plot of attack rates rather than pointrange

plot_ribbon

if TRUE, plots a ribbon over time for the attack rate estimates, otherwise plots a pointrange plot

true_ar

data frame of true attack rates with columns `population_group`, `time`, and `AR`; `time` should match `possible_exposure_times`

by_group

if TRUE, facets the plot by population_group ID

group_subset

if not NULL, plots only this subset of groups eg. 1:5

plot_residuals

if TRUE, plots the residuals between inferred and true attack rate

colour_by_taken

if TRUE, then colours the attack rates by whether or not titres against the circulating antigen at that time were measured

by_val

frequency of x-axis labels

min_time

minimum time shown on the x-axis

max_time

maximum time shown on the x-axis

settings

if not NULL, list of serosolver settings as returned from the main serosolver function, such as `res$settings`

verbose

if TRUE, prints messages when settings are used

Value

A ggplot2 object showing inferred attack rates for each potential infection time, either as pointranges, ribbons, or density plots depending on the plotting options.