plot_attack_rates: Plot historical attack rates

View source: R/plot_infection_histories.R

plot_attack_ratesR Documentation

Plot historical attack rates

Description

Plots inferred historical attack rates from the MCMC output on infection histories.

Usage

plot_attack_rates(
  infection_histories,
  antibody_data,
  possible_exposure_times,
  n_alive = NULL,
  ymax = 1,
  buckets = 1,
  pad_chain = TRUE,
  true_ar = NULL,
  by_group = FALSE,
  group_subset = NULL,
  cumulative = FALSE,
  add_box = FALSE
)

Arguments

infection_histories

the MCMC chain for infection histories

antibody_data

the data frame of antibody data

possible_exposure_times

vector of the epochs of potential infection

n_alive

vector with the number of people alive in each year of possible infection Can be left as NULL, and the 'birth' variable in 'antibody_data' will be used to calculate the number alive

ymax

Numeric. the maximum y value to put on the axis. Default = 1.

pad_chain

if TRUE, fills the infection history data table with entries for non-infection events (ie. 0s). Can be switched to FALSE for speed to get a rough idea of what the attack rates look like.

true_ar

data frame of true attack rates, with first column 'time' matching 'possible_exposure_times', and second column 'AR' giving the attack rate. Column names: population_group, time, AR

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

cumulative

if TRUE, plots the cumulative attack rate

resolution

Integer. How many buckets of time is each year split into? ie. 12 for monthly data, 4 for quarterly etc. Default = 1 for annual.

Value

a ggplot2 object with the inferred attack rates for each potential epoch of circulation


adamkucharski/serosolver documentation built on March 18, 2024, 6:07 p.m.