calculate_infection_history_statistics: Get posterior information infection histories

View source: R/analysis.R

calculate_infection_history_statisticsR Documentation

Get posterior information infection histories

Description

Finds the median, mean and 95

Usage

calculate_infection_history_statistics(
  inf_chain,
  burnin = 0,
  possible_exposure_times = NULL,
  n_alive = NULL,
  known_ar = NULL,
  group_ids = NULL,
  known_infection_history = NULL,
  solve_cumulative = FALSE
)

Arguments

inf_chain

the data table with infection history samples from serosolver

burnin

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

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.

solve_cumulative

if TRUE, finds the cumulative infection histories for each individual. This takes a while, so is left FALSE by default.

Value

a list of data frames with summary statistics

See Also

Other infection_history_plots: 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_posteriors_infhist(), plot_total_number_infections()

Examples

data(example_inf_chain)
data(example_antigenic_map)
data(example_antibody_data)
data(example_inf_hist)
possible_exposure_times <- example_antigenic_map$inf_times
## Find number alive in each time period
n_alive <- get_n_alive(example_antibody_data, possible_exposure_times)
## Get actual number of infections per time
n_infs <- colSums(example_inf_hist)
## Create data frame of true ARs
known_ar <- n_infs/n_alive
known_ar <- data.frame("j"=possible_exposure_times,"AR"=known_ar,"population_group"=1)
## Get true infection histories
known_inf_hist <- data.frame(example_inf_hist)
colnames(known_inf_hist) <- possible_exposure_times

## Need to get population_group specific n_alive and adjust to correct time frame 
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]
results <- calculate_infection_history_statistics(example_inf_chain, 0, possible_exposure_times,
                                                  n_alive=n_alive_group, known_ar=known_ar,
                                                  known_infection_history=known_inf_hist)

seroanalytics/serosolver documentation built on Dec. 14, 2024, 5:33 a.m.