Learn R Programming

epinet (version 0.0-8.1)

epibayesmcmc: Uses epidemic data to perform Bayesian inference on a contact network

Description

Performs Bayesian inference on parameters for an SEIR epidemic model and a Bernoulli random graph model, given recovery (and perhaps also exposure/infective) times for each individual infected during the course of an epidemic.

Usage

epibayesmcmc(inf.list, nsamp, thinning, bprior, tiprior, teprior, 
    pprior = c(5,N), kiprior, keprior, N, priordists="gamma", 
    betapriordist=priordists, thetaipriordist=priordists, 
    thetaepriordist=priordists, kipriordist = priordists, 
    kepriordist=priordists, extrathinning=FALSE, 
    inferEtimes = FALSE, inferItimes = FALSE, parentprobmult = 1)

Arguments

inf.list
input data consisting of exposure, infection, and recovery times, such as produced by SEIR.simulator.
nsamp
number of iterations to run MCMC algorithm.
thinning
thinning interval.
bprior
list of parameters for beta prior.
tiprior
list of parameters for thetai prior.
teprior
list of parameters for thetae prior.
pprior
list of parameters for p prior.
kiprior
list of parameters for ki prior.
keprior
list of parameters for ke prior.
N
number of people in the population. Assumed to be fixed and known.
priordists
can be uniform or gamma.
betapriordist
can be uniform or gamma.
thetaipriordist
can be uniform or gamma.
thetaepriordist
can be uniform or gamma.
kipriordist
can be uniform or gamma.
kepriordist
can be uniform or gamma.
extrathinning
set to FALSE unless we want to return inferred values of the exposure / infective times and the transmission tree, in which case it is an integer specifying the extra thinning interval.
inferEtimes
boolean variable specifying whether the exposure times are considered known (FALSE) or if they are unknown and need to be inferred (TRUE).
inferItimes
boolean variable specifying whether the infective times are considered known (FALSE) or if they are unknown and need to be inferred (TRUE).
parentprobmult
multiplier for prior probability placed on suspected parent node. Default is a uniform prior assumption.

Value

  • acceptvector containing the number of times a proposed new value was accepted for the parameters (P, p, G, beta, thetai, ki, thetae, ke).
  • proposevector containing the number of times a new value was proposed for the parameters (P, p, G, beta, thetai, ki, thetae, ke).
  • betavector containing the sample for parameter beta.
  • thetaivector containing the sample for parameter thetai.
  • thetaevector containing the sample for parameter thetae.
  • kivector containing the sample for parameter ki.
  • kevector containing the sample for parameter ke.
  • pvector containing the sample for parameter p.
  • initexpvector containing the sample for parameter kappa (identity of initial exposed). Will only vary when both the exposure and infection times are assumed unknown.
  • initexptimevector containing the sample for parameter $E_{\kappa}$ (initial exposure time). Will only vary when the exposure times are assumed unknown.
  • exptimesif inferEtimes is TRUE, this is two-dimensional array containing the inferred exposure times (exptimes[i, ] contains the sample of exposure times for node i). If inferEtimes is FALSE, this will be NULL.
  • inftimesif inferItimes is TRUE, this is two-dimensional array containing the inferred infective times (inftimes[i, ] contains the sample of infective times for node i). If inferItimes is FALSE, this will be NULL.
  • rectimesvector containing the original recovery times.
  • transtreeA two-dimensional array containing the sample for inferred transmission tree. transtree[i, ] contains the sample of parent nodes for node i. A parent node of -999 for i designates that i is the initial exposed node.

Details

Uses exposed, infective, and removal times from the infected nodes of an epidemic in order to perform inference on the parameters of the network and epidemic models.

inf.list is an $m$ row by 5 column array giving the identity, likely parent, and exposed, infective, and removal times for each of the $m$ nodes that were infected during the course of the epidemic. Column 1 gives the ID (an integer) of the node, and column 2 gives the identity of the probable parent of the node (if known). Columns 3, 4, and 5 give the exposed, infective, and removal times. Note that if these times are not internally consistent, an error message will be generated and no inference will be performed. It is necessary to include data for exposure and infective times, even if these values are not known (in this case, set the respective columns of data to NA).

nsamp is the number of samples that will be produced for each of the model parameters.

thinning is the thinning interval, e.g., to return every $10^{th}$ sample, use thinning = 10.

The type of prior distribution (default is gamma / inverse gamma) can be specified for all parameters using priordists or for each parameter individually. The prior distribution for p is always the beta distribution (set both hyper-parameters of this prior to 1 to get a uniform distribution). For the other parameters, either uniform or gamma / inverse gamma priors can be chosen. (The two theta parameters use inverse gamma prior distributions, while the other parameters use gamma priors.)

The parameters of the prior distributions are given as lists of (two) hyper-parameters. If the uniform prior is being used for a parameter, then the hyper-parameters are the lower and upper limits of the distribution. If the gamma distribution is being used with parameters $c$ and $d$, then the prior mean is $c \cdot d$ and the prior variance is $c \cdot d^2$. If the inverse gamma distribution is being used with parameters $c$ and $d$, then the prior mean is $\frac{d}{c-1}$ and the prior variance is $\frac{d^2}{(c-1)^2 \cdot (c-2)}$.

The boolean variables inferEtimes and inferItimes indicate whether the exposure and infective times respectively are assumed to be unknown (need to be inferred by the algorithm) or are assumed to be known (and are not updated in the algorithm). If data exposure and / or infective times are not known, set the respective columns of data to NA (any data passed to the function when will be ignored).

If exposure and / or infective times are being inferred and we wish to return the inferred values of these times (along with the inferred transmission tree), set extrathinning equal to an integer specifying the extra thinning interval for these values. Because returning values for a large number of nodes can be very space-intensive, an extra thinning interval can be given as a multiple of the thinning interval for the other parameters. For example, using thinning = 10 and extrathinning = 20 will return the values of the inferred exposure and infective times and transmission tree every 200 iterations, and the values of the other parameters every 10 iterations. If these inferred values are not desired, set this variable to FALSE.

The default prior distribution for the parent of each node is uniform on all of the other nodes. To specify a non-uniform distribution, use column 2 of inf.list and set parentpriormult to an integer multiplier greater than 1.

Uses an algorithm similar to that described in Groendyke et al. (2010) and Britton and O'Neill (2002).

References

Groendyke, C., Welch, D. and Hunter, D. (2010) Bayesian inference for contact networks given epidemic data, Technical Report, Department of Statistics, Pennsylvania State University, 10-02 http://www.stat.psu.edu/reports/2010/TR10-02.pdf Britton, T. and O'Neill, P.D. 2002. Bayesian inference for stochastic epidemics in populations with random social structure, Scandinavian Journal of Statistics, 29-3

See Also

SEIR.simulator for simulating an SEIR epidemic over an Erdos-Renyi network, Hagelloch for an example epidemic data set, and PlotEpiTree for plotting the epidemic.

Examples

Run this code
# Simulate an epidemic through a network of 30
set.seed(1)
examplenet <- buildER(N = 30, p = 0.1)
exampleepidemic <- SEIR.simulator(examplenet, N = 30, 
    beta = 0.3, ki = 2, thetai = 5, latencydist = "gamma")

# Run MCMC algorithm on this epidemic
examplemcmc <- epibayesmcmc(exampleepidemic, nsamp = 100000, 
    thinning = 100, bprior = c(0, 1), tiprior = c(0, 5), teprior = c(0, 5), 
    kiprior = c(0, 10), keprior = c(0, 10), N = 30, priordists = "uniform")

Run the code above in your browser using DataLab