tsglm.sim

0th

Percentile

Simulate a Time Series Following a Generalised Linear Model

Generates a simulated time series from a GLM-type 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 non-negative vector containing the coefficients $\beta[1], \ldots, \beta[p]$ for regression on previous observations (see Details).

past_mean
numeric non-negative vector containing the coefficients $\alpha[1], \ldots, \alpha[q]$ for regression on previous conditional means (see Details).

xreg
numeric non-negative 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 and external (see function tsglm for details). This model specification must be in accordance to the parameters given in argument param.
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 so-called INGARCH model. Another possible choice is "log", simulating from a log-linear 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. For distr="nbinom" the additional parameter size needs to be specified (e.g. by distrcoefs=2), see tsglm for details.
fit
an object of class "tsglm". Usually the result of a call to tsglm. If argument fit 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 arguments model, link and param. The length of the simulated time series is only taken from argument fit, if no argument n is provided. The same holds for arguments xreg, distr and distrcoefs, which are also prefered over the respective information provided in argument fit if both are provided.
n_start
number of observations used as a burn-in.
Details

The definition of the model used here is like in function tsglm.

Note that during the burn-in period covariates are set to zero.

If a previous model fit is given in argument fit and the length of the burn-in 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.

Aliases
  • tsglm.sim
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))
Documentation reproduced from package tscount, version 1.3.0, License: GPL-2 | GPL-3

Community examples

Looks like there are no examples yet.