MCMC: Make inference on a General Stochastic Epidemic

Description Usage Arguments Details Value Examples

View source: R/MCMC.R

Description

This function uses realistically available information from a GSE to perform Bayesian inference and attempt to recover the parameters.

Usage

1
2
3
4
5
6
MCMC(N.its, N, inf.ids, rem.times, dist.mat, lambda.b1 = 0.001,
  nu.b1 = 1, lambda.b2 = 0.001, nu.b2 = 1, lambda.g = 0.001,
  nu.g = 1, inc.beta1 = list(NA, T), inc.beta2 = list(NA, T),
  inc.dist = list(NA, T), inc.inf.times = list(NA, T),
  inc.gamma = list(NA, T), d.upper, sigmab1, sigmab2, sigmad,
  infupdate = 1)

Arguments

N.its

The number of desired iterations of the MCMC algorithm.

N

The total size of the population.

inf.ids

A vectors of the IDs of the infected individuals.

rem.times

A vector of the removal times, ordered by individual ID.

dist.mat

An NxN distance matrix.

lambda.b1

The rate parameter for beta1, assuming a Gamma prior.

nu.b1

The shape parameter for beta1, assuming a Gamma prior.

lambda.b2

The rate parameter for beta2, assuming a Gamma prior.

nu.b2

The shape parameter for beta2, assuming a Gamma prior.

lambda.g

The rate parameter for gamma, assuming a Gamma prior.

nu.g

The shape parameter for gamma, assuming a Gamma prior.

inc.beta1

A list object of 2 levels, the true value of beta1, and T/F binary value that says whether to make inference on beta1 (T = make inference, see details for the different options).

inc.beta2

See inc.beta1, but for beta2.

inc.dist

See inc.beta1, but for the distance d.

inc.inf.times

A list object of 2 levels; a vector of the true infection times, and T/F binary value that says whether to make inference on the infection times (T = make inference, see details for the different options).

inc.gamma

See inc.beta1, but for the removal rate gamma.

d.upper

The upper bound on the distance d.

sigmab1

Tuning parameter. The standard deviation of the multiplicative random walk for beta1.

sigmab2

Tuning parameter. The standard deviation of the multiplicative random walk for beta1.

sigmad

Tuning parameter. The standard deviation of the folded random walk for d.

infupdate

Tuning parameter. The number of infection times that should be updated at each iteration.

Details

The function has the functionality to allow the fixing of some (or all) parameters. For the function parameters that begin inc. a list can be fed to them of the form (true parameter value(s), TRUE/FALSE), where the TRUE dictates that inference should be made for that parameter. Possible options for this list are; list(parameters, F) in which case the function will fix that parameter value, list(NA, T) in which case the function will randomly generate a valid initial value for the parameter and then make inference, list(parameter, T) in which case the function will initialise the parameter at its true value and then make inference, or (NA, F) which we do not suggest using as it will fix the parameter at a random value.

Gamma is always assumed to be initialised at the value 0.15.

Value

This function returns a list object with elements; a matrix of results (which included all the accepted samples and the log-likelihood at the end of each iteration), the acceptance rate of the infection times, the acceptance rate of beta1, the acceptance rate of beta2, and the acceptance rate of d.

Examples

1
2
3
4
5
inference <- MCMC(N.its = 100000, N = 10, inf.ids, rem.times, dist.mat, 
lambda.b1 = 0.001, nu.b1 = 1, lambda.b2 = 0.001, nu.b2 = 1, lambda.g = 0.001 , nu.g = 1,
inc.beta1 = list(0.004, T), inc.beta2 = list(NA, T), inc.dist = list(NA, T),
inc.inf.times = list(inf.times, F), inc.gamma = list(NA, T),
d.upper = 1.5, sigmab1 = 1, sigmab2 = 1, sigmad = 2, infupdate = 1)

BenjamenSimon/EpidemicR documentation built on March 23, 2020, 11:03 p.m.