plot_prob_infection: Plot probability of infection

View source: R/plots.R

plot_prob_infectionR Documentation

Plot probability of infection

Description

Plot probabilities of infection from compartmental model. Returns the probabilities and the plot.

Usage

plot_prob_infection(
  chain,
  nsamps,
  INCIDENCE_FUNC,
  solve_times,
  obs_dat = NULL,
  true_prob_infection = NULL,
  tshift = 0,
  smooth = FALSE
)

Arguments

chain

A dataframe containing the MCMC samples

nsamps

Number of samples

INCIDENCE_FUNC

A pointer to the Gaussian process model

solve_times

Vector indicating the time over which the model is solved

obs_dat

A dataframe containing observed Ct values and time of sample collection. NULL by default.

true_prob_infection

A dataframe from simulated data with two columns, one for time and the other is the true probability of infection. NULL by default.

tshift

Shift the solve times? Numeric, set to 0 by default

smooth

Smooth the model estimates for plotting? FALSE by default.

Value

Return a list containing three things: 1. A dataframe of model predictions containing time, probability of infection, and sample number; 2. A dataframe containing the maximum posterior probability of infection and time; 3. A ggplot showing the probabilities of infection

Author(s)

James Hay, jhay@hsph.harvard.edu

See Also

Other plots: plot_distribution_fits(), predicted_distribution_fits()

Examples

data(example_seir_incidence)
predictions <- plot_prob_infection(chain_comb, 
                                 nsamps=100, 
                                 INCIDENCE_FUNC=incidence_function,
                                 solve_times=0:max(ct_data_use$t),
                                 obs_dat=ct_data_use,
                                 true_prob_infection=example_seir_incidence)
p_incidence_prediction <- predictions$plot + scale_x_continuous(limits=c(0,200))
p_incidence_prediction


jameshay218/virosolver documentation built on April 17, 2025, 2:57 p.m.