| mcmcSEIR | R Documentation |
Run the MCMC algorithm to obtain posterior samples for all model parameters.
mcmcSEIR(
dat,
X,
inits,
niter,
nburn,
infPeriodSpec = c("exp", "PS", "IDD"),
priors,
iddFun = NULL,
maxInf = NULL,
dist = NULL,
EKnown = FALSE,
WAIC = FALSE,
progressBar = FALSE,
seed = NULL
)
dat |
A list providing the necessary data on the epidemic. Must contain
|
X |
The design matrix corresponding to the intensity process over epidemic time. |
inits |
A list of initial values for all parameters. Must contain initial
values for beta vector with elements for each column of |
niter |
The total number of iterations to be run. |
nburn |
The number of burn-in iterations to be discarded. |
infPeriodSpec |
A character indicating which model for the infectious period will be used. |
priors |
A list of functions to compute the prior probability for each parameter. Functions must take only one argument and must compute the probability on the log scale. |
iddFun |
If |
maxInf |
If |
dist |
If |
EKnown |
logical. If |
WAIC |
logical. If |
progressBar |
logical. If |
seed |
optional seeding for reproducibility. |
mcmcSEIR offers modelers three options to specify the infectious
period: the exponential distribution, the path-specific (PS) approach of Porter and Oleson (2013),
or the infectious-duration dependent (IDD) formulation of Ward et al. (upcoming).
All models will estimate a beta parameter associated with each column of the
matrix X and a rate parameter rateE associated with the exposure
probability.
For the exponential model infPeriodSpec = 'exp', only one additional parameter
will be estimated: rateI the rate parameter associated with the removal
probability. Initial values and a prior for rateI need to be specified.
For the path-specific model infPeriodSpec = 'PS', additional parameters
corresponding to the distribution specified in dist will be estimated.
Initial values are named as psParams, which itself is a list with
initial values for each associated parameter. Function giving priors for
these parameters should be named psParamsPrior and
contained in priors. For example, if dist = 'gamma', then
inits$psParams = list(shape = , rate = ) will provide the initial
values for the shape and rate parameters associated
with the gamma distribution. priors$psParamsPriors should
contain a function which computes the joint prior for these parameters.
For the infectious-duration dependent model infPeriodSpec = 'IDD',
additional parameters corresponding to the IDD curve specified in iddFun
will also be estimated. Initial values are named as iddParams, which
itself is a list with initial values for each associated parameter. Function
giving priors for these parameters should be named iddParamsPrior and
contained in priors. For example, if iddFun = logitIDD, then
inits$iddParams = list(rate = ..., mid = ...) will provide the initial
values and priors$iddParamsPriors should contain a function which computes
the joint prior for these parameters (see example).
If WAIC = TRUE, the WAIC will be calculated. WAIC is computed based on the
log-likelihood values at each post burn-in iteration using the pWAIC2
formulation described in Gelman et al. (2013), which multiplies the WAIC of
Watanabe (2010) by 2 to be on the deviance scale.
A data frame of posterior samples or a two-element list with posterior samples and WAIC.
Porter, Aaron T., and Oleson, Jacob J. "A path-specific SEIR model for use with general latent and infectious time distributions." Biometrics 69.1 (2013): 101-108.
Gelman, Andrew, Hwang, Jessica and Vehtari, Aki. "Understanding predictive information criteria for Bayesian models." Statistics and computing 24.6 (2014): 997-1016.
Watanabe, Sumio, and Opper, Manfred. "Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory." Journal of machine learning research 11.12 (2010).
## Not run:
dat <- simSEIR(S0=999, E0=0, I0=1, N=1000, tau=100,
beta=0.7, X=cbind(rep(1, 100)), rateE=0.1,
infPeriodSpec = 'IDD',
infIDDParams = list(maxInf = 15,
iddFun = logitIDD,
iddParams = list(mid = 8, rate = 1.5)))
initsList <- list(beta = 1, rateE = 0.2,
iddParams = list(mid = 4, rate = 0.1))
priorsList <- list(betaPrior = function(x) dnorm(x, 0, 4, log = T),
rateEPrior = function(x) dgamma(x, 10, 100, log = T),
iddParamsPrior = function(x) {
dnorm(x["mid"], 5, 1, log = T) +
dgamma(x["rate"], 1, 1, log = T)
})
postRes <- mcmcSEIR(dat = dat, X=cbind(rep(1, 100)),
inits = initsList,
niter=10000, nburn=5000,
infPeriodSpec = 'IDD',
priors=priorsList,
iddFun = logitIDD, maxInf = 10,
progressBar = T)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.