Description Usage Arguments Value Model Randomness Examples
make_data()
simulates time series data according to a system of
SIR equations and a supplied list of parameter values. Observations
are recorded at equally spaced time points
t_{k} = t_{0}+kΔt
(for k = 0,...,n),
where
Δt
denotes the observation interval.
1 2 3 4 5 6 7 
par_list 
A list containing:

n 
Numeric scalar. Time between the first and last observations
in units
Δt,
so that simulated time series have 
with_dem_stoch 
Logical scalar. If 
seed 
Integer scalar or 
ode_control 
A list of arguments to be passed to

A data frame with numeric columns:
t
Time in units
Δt.
Equal to t0 + seq(0, n, by = 1)
.
t_years
Time in years. Equal to
(t0 + seq(0, n, by = 1)) * dt_weeks * (7 / 365)
.
beta
Seasonally forced transmission rate expressed per unit Δt, per susceptible per infected, without environmental noise.
beta_phi
Seasonally forced transmission rate expressed per unit Δt per susceptible per infected, with environmental noise.
N
Population size.
S
Number of susceptibles.
I
Number of infecteds.
R
Number of removeds.
Q
Cumulative incidence. Q[i]
is the number of infections
between times t[1]
and t[i]
.
Z
Incidence. Z[i]
is the number of infections
between times t[i1]
and t[i]
, computed as Q[i]  Q[i1]
.
C
Reported incidence. C[i]
is the number of infections
reported between times t[i1]
and t[i]
, equal to the number
of successes in Z[iround(trep)]
independent Bernoulli trials,
with success probability
p_{rep}.
A list of the arguments of make_data()
is included as an attribute.
make_data()
generates data at times
t_{k} = t_{0}+kΔt
(for k = 0,...,n)
using the system of SIR equations
with γ = 1 / t_{gen} and β(t) = ⟨β⟩ (1 + α cos(2πt / (1 year) + ϕ(t;ϵ))), where ϕ(t;ϵ) is the linear interpolant of random noise {(t_{k},Φ_{k})} with Φ_{k} ~ Normal(0,ϵ^{2}).
Simulations have three sources of randomness:
Environmental stochasticity
The seasonal forcing function contains a randomly generated
phase shift
ϕ(t;ϵ).
Randomness is introduced by choosing epsilon
greater than 0.
Demographic stochasticity
If with_dem_stoch = TRUE
, then observations are generated
by realizing a continuoustime stochastic process, in which
event probabilities are determined by terms in the ODE.
See adaptivetau::ssa.adaptivetau()
.
Probability of infected decrease is set to zero whenever the number of infecteds is 1, in order to prevent disease fadeout.
If with_dem_stoch = FALSE
, then observations are generated
by numerically integrating the ODE. See deSolve::ode()
.
Underreporting of cases
Reported incidence C
is obtained from incidence Z
by modeling C[i]
as the number of successes in
Z[iround(trep)]
independent Bernoulli trials,
with success probability
p_{rep}.
Randomness is introduced by choosing prep
in (0,1).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  # Deterministic simulation
par_list < make_par_list(dt_weeks = 1)
df < make_data(
par_list = par_list,
n = 20 * 365 / 7, # 20 years is ~1042 weeks
with_dem_stoch = FALSE # numerical integration of d(S,I,R)/dt
)
head(df)
# Reproducible stochastic simulation
par_list < make_par_list(
dt_weeks = 1,
epsilon = 0.5, # s.d. of environmental noise
prep = 0.5 # case reporting probability
)
df < make_data(
par_list = par_list,
n = 20 * 365 / 7, # 20 years is ~1042 weeks
with_dem_stoch = TRUE, # stochastic simulation of d(S,I,R)/dt
seed = 5 # seed for RNG
)
head(df)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.