Compares observed antibody measurements with posterior predictions and returns the prediction data and comparison plots.

plot_antibody_predictions(
  chain,
  infection_histories,
  antibody_data = NULL,
  demographics = NULL,
  par_tab = NULL,
  antigenic_map = NULL,
  possible_exposure_times = NULL,
  nsamp = 1000,
  measurement_bias = NULL,
  data_type = 1,
  start_level = "none",
  settings = NULL,
  exponential_waning = NULL,
  verbose = FALSE
)

Arguments

chain

the full MCMC chain to generate antibody level trajectories from, usually `chains$theta_chain`

infection_histories

the MCMC chain for infection histories, usually `chains$inf_chain`

antibody_data

the antibody data frame, with one row per measurement

demographics

optional data frame identifying the demographic group for each individual. This is used when model parameters are stratified by demographics. See the [demographic stratification and covariate vignette](https://seroanalytics.github.io/serosolver/articles/demographics_covariates.html).

par_tab

the model control table specifying the parameters in the MCMC chain

antigenic_map

(optional) a data frame of antigenic x and y coordinates. Must have column names: x_coord; y_coord; inf_times. The `inf_times` column identifies the circulation or exposure time represented by each map entry. See example_antigenic_map

possible_exposure_times

(optional) if no antigenic map is specified, this argument gives the vector of times at which individuals can be infected

nsamp

number of draws to take from the posterior

measurement_bias

default NULL, optional data frame mapping each `biomarker_id` and `biomarker_group` combination to the `rho_index` of the measurement-shift parameter that it uses. See the [advanced features vignette](https://seroanalytics.github.io/serosolver/articles/advanced_features.html).

data_type

numeric or text value: `1` or `"discrete"` for discrete, bounded data; `2` or `"continuous"` for continuous, bounded data; or `3` or `"false_positive"` for continuous data with the false-positive observation model. Supply one value per biomarker group, or one value to use for all groups. For bounded data, the limits are given by `min_measurement` and `max_measurement` in par_tab.

start_level

`"none"` or a starting-level summary or data frame. A starting level is the antibody level assigned before the modelled infection history begins. With `"none"`, starting levels are set to zero. See the [advanced features vignette](https://seroanalytics.github.io/serosolver/articles/advanced_features.html).

settings

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

exponential_waning

Deprecated compatibility argument. Prefer a fixed `exponential_waning` row in `par_tab`, with `values = 1` and `par_type = 0`.

verbose

if TRUE, prints messages when settings are used or predictions are prepared

Value

a list with:

  • a data frame with all posterior estimates for each observation;

  • the proportion of observations captured by the 95

  • a histogram comparing posterior median estimates to the observed data (note, this can be misleading for continuous data due to the zero-inflated observation model);

  • a histogram comparing random posterior draws to the observed data (can be more reliable than posterior medians);

  • comparison of observations and all posterior medians and 95