forecast (version 5.4)

simulate.ets: Simulation from a time series model

Description

Returns a time series based on the model object object.

Usage

## S3 method for class 'ets':
simulate(object, nsim=length(object$x), seed=NULL, future=TRUE, 
    bootstrap=FALSE, innov=NULL, ...)
## S3 method for class 'ar':
simulate(object, nsim=object$n.used, seed=NULL, future=TRUE, 
    bootstrap=FALSE,  innov=NULL, ...)
## S3 method for class 'Arima':
simulate(object, nsim=length(object$x), seed=NULL, xreg=NULL, future=TRUE, 
    bootstrap=FALSE,  innov=NULL, lambda=object$lambda, ...)
## S3 method for class 'fracdiff':
simulate(object, nsim=object$n, seed=NULL, future=TRUE, 
    bootstrap=FALSE,  innov=NULL, ...)

Arguments

object
An object of class "ets", "Arima" or "ar".
nsim
Number of periods for the simulated series
seed
Either NULL or an integer that will be used in a call to set.seed before simulating the time series. The default, NULL will not change the random generator state.
future
Produce sample paths that are future to and conditional on the data in object.
bootstrap
If TRUE, simulation uses resampled errors rather than normally distributed errors.
innov
A vector of innovations to use as the error series. If present, bootstrap and seed are ignored.
xreg
New values of xreg to be used for forecasting. Must have nsim rows.
lambda
Box-Cox parameter. If not NULL, the simulated series is transformed using an inverse Box-Cox transformation with parameter lamda.
...
Other arguments.

Value

  • An object of class "ts".

Details

With simulate.Arima(), the object should be produced by Arima or auto.arima, rather than arima. By default, the error series is assumed normally distributed and generated using rnorm. If innov is present, it is used instead. If bootstrap=TRUE and innov=NULL, the residuals are resampled instead.

See Also

ets, Arima, auto.arima, ar, arfima.

Examples

Run this code
fit <- ets(USAccDeaths)
plot(USAccDeaths,xlim=c(1973,1982))
lines(simulate(fit, 36),col="red")

Run the code above in your browser using DataCamp Workspace