Description Usage Arguments Details Value Author(s) References See Also Examples
Simulates a multivariate time series of counts based on the Poisson/Negative Binomial model as described in Paul and Held (2011).
1 2 3 4 
object 
an object of class 
nsim 
number of time series to simulate. Defaults to 
seed 
an object specifying how the random number generator should be
initialized for simulation (via 
y.start 
vector or matrix (with 
subset 
time period in which to simulate data. Defaults to the whole period. 
coefs 
coefficients used for simulation from the model in 
components 
character vector indicating which components of the fitted model

simplify 
logical indicating if only the simulated counts ( 
... 
unused (argument of the generic). 
Simulates data from a Poisson or a Negative Binomial model with mean
μ_it = λ_it y_i,t1 + φ_it ∑_j w_ji y_j,t1 + ν_it
where
λ_{it}>0, φ_{it}>0, and ν_{it}>0 are
parameters which are modelled parametrically.
The function uses the model and parameter estimates of the fitted
object
to simulate the time series.
With the argument coefs
it is possible to simulate from
the model as specified in object
, but with different
parameter values.
If simplify=FALSE
: an object of class
"sts"
(nsim = 1
) or a list of those
(nsim > 1
).
If simplify=TRUE
: an object of class
"hhh4sims"
, which is an array of dimension
c(length(subset), ncol(object$stsObj), nsim)
, where the third
dimension is dropped if nsim=1
(yielding a matrix).
The originally observed counts during the simulation period,
object$stsObj[subset,]
, are attached for reference
(used by the plot
methods) as an attribute "stsObserved"
,
and the initial condition y.start
as attribute "initial"
.
Michaela Paul and Sebastian Meyer
Paul, M. and Held, L. (2011) Predictive assessment of a nonlinear random effects model for multivariate time series of infectious disease counts. Statistics in Medicine, 30, 1118–1136
plot.hhh4sims
and scores.hhh4sims
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  data(influMen)
# convert to sts class and extract meningococcal disease time series
meningo < disProg2sts(influMen)[,2]
# fit model
fit < hhh4(meningo, control = list(ar = list(f = ~ 1),
end = list(f = addSeason2formula(S = 1, period = 52)),
family = "NegBin1"))
plot(fit)
# simulate from model
simData < simulate(fit, seed=1234)
# plot simulated data
plot(simData, main = "simulated data", xaxis.labelFormat=NULL)
# consider a Poisson instead of a NegBin model
coefs < coef(fit)
coefs["overdisp"] < 0
simData2 < simulate(fit, seed=123, coefs = coefs)
plot(simData2, main = "simulated data: Poisson model", xaxis.labelFormat = NULL)
# consider a model with higher autoregressive parameter
coefs < coef(fit)
coefs[1] < log(0.5)
simData3 < simulate(fit, seed=321, coefs = coefs)
plot(simData3, main = "simulated data: lambda = 0.5", xaxis.labelFormat = NULL)

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