tsglm
for details).
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)
intercept
past_obs
past_mean
xreg
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
.
tsglm
for details). Its number of rows must be equal to the number of observations which should be simulated.
"identity"
, simulating from a so-called INGARCH model. Another possible choice is "log"
, simulating from a log-linear model.
"poisson"
, i.e. a Poisson distribution.
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.
"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.
ts
"ts"
with the simulated time series.
linear.predictors
"ts"
with the simulated linear predictors $\kappa[t]$ for all $t=1, \ldots, n$.
xreg.effects
"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$.
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.
tsglm
for fitting a GLM for time series of counts.
#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))
Run the code above in your browser using DataLab