File: make_mcmc_control.Rd

package info (click to toggle)
r-cran-epiestim 2.2-4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 636 kB
  • sloc: sh: 15; makefile: 2
file content (101 lines) | stat: -rw-r--r-- 3,845 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make_mcmc_control.R
\name{make_mcmc_control}
\alias{make_mcmc_control}
\title{make_mcmc_control Creates a list of mcmc control parameters to be used in 
\code{config$mcmc_control}, where \code{config} is an argument of the 
\code{estimate_R} function. This is used to configure the MCMC chain used to 
estimate the serial interval within \code{estimate_R} (with method 
"si_from_data").}
\usage{
make_mcmc_control(
  burnin = 3000,
  thin = 10,
  seed = as.integer(Sys.time()),
  init_pars = NULL
)
}
\arguments{
\item{burnin}{A positive integer giving the burnin used in the MCMC when
estimating the serial interval distribution.}

\item{thin}{A positive integer corresponding to thinning parameter; the MCMC
will be run for \code{burnin+n1*thin iterations}; 1 in \code{thin}
iterations will be recorded, after the burnin phase, so the posterior
sample size is n1.}

\item{seed}{An integer used as the seed for the random number generator at
the start of the MCMC estimation; useful to get reproducible results.}

\item{init_pars}{vector of size 2 corresponding to the initial values of
parameters to use for the SI distribution. This is the shape and scale for
all but the lognormal distribution, for which it is the meanlog and
sdlog.}
}
\value{
An object of class \code{estimate_R_mcmc_control} with components 
burnin, thin, seed, init_pars. This can be 
used as an argument of function \code{make_config}.
}
\description{
make_mcmc_control Creates a list of mcmc control parameters to be used in 
\code{config$mcmc_control}, where \code{config} is an argument of the 
\code{estimate_R} function. This is used to configure the MCMC chain used to 
estimate the serial interval within \code{estimate_R} (with method 
"si_from_data").
}
\details{
The argument \code{si_data}, should be a dataframe with 5
 columns:
\itemize{
\item{EL: the lower bound of the symptom onset date of the infector (given as
 an integer)}
\item{ER: the upper bound of the symptom onset date of the infector (given as
 an integer). Should be such that ER>=EL}
\item{SL: the lower bound of the symptom onset date of the infected
individual (given as an integer)}
\item{SR: the upper bound of the symptom onset date of the infected
individual (given as an integer). Should be such that SR>=SL}
\item{type (optional): can have entries 0, 1, or 2, corresponding to doubly
interval-censored, single interval-censored or exact observations,
respectively, see Reich et al. Statist. Med. 2009. If not specified, this
will be automatically computed from the dates}
}
Assuming a given parametric distribution for the serial interval distribution
 (specified in \code{si_parametric_distr}),
the posterior distribution of the serial interval is estimated directly fom
these data using MCMC methods implemented in the package
}
\examples{
\dontrun{
## Note the following examples use an MCMC routine
## to estimate the serial interval distribution from data,
## so they may take a few minutes to run

## load data on rotavirus
data("MockRotavirus")

## estimate the reproduction number (method "si_from_data")
mcmc_seed <- 1
burnin <- 1000
thin <- 10
mcmc_control <- make_mcmc_control(burnin = burnin, thin = thin, 
                     seed = mcmc_seed)

incid <- MockRotavirus$incidence
method <- "si_from_data"
overall_seed <- 2
config <- make_config(incid = incid, 
                     method = method, 
                     si_parametric_distr = "G",
                     mcmc_control = mcmc_control,
                     n1 = 500
                     n2 = 50,
                     seed = overall_seed)

R_si_from_data <- estimate_R(incid,
                            method = method,
                            si_data = MockRotavirus$si_data,
                            config = config)
}
}