tsglm.sim
From tscount v1.3.0
by Tobias Liboschik
Simulate a Time Series Following a Generalised Linear Model
Generates a simulated time series from a GLMtype model for time series of counts (see tsglm
for details).
 Keywords
 Simulation
Usage
tsglm.sim(n, param = list(intercept = 1, past_obs = NULL, past_mean = NULL, xreg = NULL), model = list(past_obs = NULL, past_mean = NULL, external = FALSE), xreg = NULL, link = c("identity", "log"), distr = c("poisson", "nbinom"), distrcoefs, fit, n_start = 50)
Arguments
 n
 integer value giving the number of observations to be simulated.
 param

a named list giving the parameters for the linear predictor of the model, which has the following elements:
intercept
 numeric positive value for the intercept $\beta[0]$.
past_obs
 numeric nonnegative vector containing the coefficients $\beta[1], \ldots, \beta[p]$ for regression on previous observations (see Details).
past_mean
 numeric nonnegative vector containing the coefficients $\alpha[1], \ldots, \alpha[q]$ for regression on previous conditional means (see Details).
xreg
 numeric nonnegative vector specifying the size $\nu[1], \ldots, \nu[r]$ of each intervention
 model

a named list specifying the model for the linear predictor, which has the elements
past_obs
,past_mean
andexternal
(see functiontsglm
for details). This model specification must be in accordance to the parameters given in argumentparam
.  xreg

matrix with covariates in the columns (see
tsglm
for details). Its number of rows must be equal to the number of observations which should be simulated.  link

character giving the link function. Default is
"identity"
, simulating from a socalled INGARCH model. Another possible choice is"log"
, simulating from a loglinear model.  distr

character giving the conditional distribution. Default is
"poisson"
, i.e. a Poisson distribution.  distrcoefs

numeric vector of additional coefficients specifying the conditional distribution. For
distr="poisson"
no additional parameters need to be provided. Fordistr="nbinom"
the additional parametersize
needs to be specified (e.g. bydistrcoefs=2
), seetsglm
for details.  fit

an object of class
"tsglm"
. Usually the result of a call totsglm
. If argumentfit
is not missing, the specification of the linear predictor, the link function and the estimated parameters from this argument are used instead of those in argumentsmodel
,link
andparam
. The length of the simulated time series is only taken from argumentfit
, if no argumentn
is provided. The same holds for argumentsxreg
,distr
anddistrcoefs
, which are also prefered over the respective information provided in argumentfit
if both are provided.  n_start
 number of observations used as a burnin.
Details
The definition of the model used here is like in function tsglm
.
Note that during the burnin period covariates are set to zero.
If a previous model fit is given in argument fit
and the length of the burnin period n_start
is set to zero, then the a continuation of the original time series is simulated.
Value

A list with the following components:
ts

an object of class
"ts"
with the simulated time series. linear.predictors

an object of class
"ts"
with the simulated linear predictors $\kappa[t]$ for all $t=1, \ldots, n$. xreg.effects

an object of class
"ts"
with the cumulated effect of the covariates $\eta[1] X[t,1] + \ldots + \eta[r] X[t,r]$ for all $t=1, \ldots, n$.
See Also
tsglm
for fitting a GLM for time series of counts.
Examples
#Simulate from an INGARCH model with two interventions:
interventions < interv_covariate(n=200, tau=c(50, 150), delta=c(1, 0.8))
model < list(past_obs=1, past_mean=c(1, 7), external=FALSE)
param < list(intercept=2, past_obs=0.3, past_mean=c(0.2, 0.1), xreg=c(3, 10))
tsglm.sim(n=200, param=param, model=model, xreg=interventions, link="identity",
distr="nbinom", distrcoefs=c(size=1))
Community examples
Looks like there are no examples yet.