1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/simulate.R
3\name{simulate.ets}
4\alias{simulate.ets}
5\alias{simulate.Arima}
6\alias{simulate.ar}
7\alias{simulate.lagwalk}
8\alias{simulate.fracdiff}
9\alias{simulate.nnetar}
10\alias{simulate.modelAR}
11\title{Simulation from a time series model}
12\usage{
13\method{simulate}{ets}(
14  object,
15  nsim = length(object$x),
16  seed = NULL,
17  future = TRUE,
18  bootstrap = FALSE,
19  innov = NULL,
20  ...
21)
22
23\method{simulate}{Arima}(
24  object,
25  nsim = length(object$x),
26  seed = NULL,
27  xreg = NULL,
28  future = TRUE,
29  bootstrap = FALSE,
30  innov = NULL,
31  lambda = object$lambda,
32  ...
33)
34
35\method{simulate}{ar}(
36  object,
37  nsim = object$n.used,
38  seed = NULL,
39  future = TRUE,
40  bootstrap = FALSE,
41  innov = NULL,
42  ...
43)
44
45\method{simulate}{lagwalk}(
46  object,
47  nsim = length(object$x),
48  seed = NULL,
49  future = TRUE,
50  bootstrap = FALSE,
51  innov = NULL,
52  lambda = object$lambda,
53  ...
54)
55
56\method{simulate}{fracdiff}(
57  object,
58  nsim = object$n,
59  seed = NULL,
60  future = TRUE,
61  bootstrap = FALSE,
62  innov = NULL,
63  ...
64)
65
66\method{simulate}{nnetar}(
67  object,
68  nsim = length(object$x),
69  seed = NULL,
70  xreg = NULL,
71  future = TRUE,
72  bootstrap = FALSE,
73  innov = NULL,
74  lambda = object$lambda,
75  ...
76)
77
78\method{simulate}{modelAR}(
79  object,
80  nsim = length(object$x),
81  seed = NULL,
82  xreg = NULL,
83  future = TRUE,
84  bootstrap = FALSE,
85  innov = NULL,
86  lambda = object$lambda,
87  ...
88)
89}
90\arguments{
91\item{object}{An object of class "\code{ets}", "\code{Arima}", "\code{ar}"
92or "\code{nnetar}".}
93
94\item{nsim}{Number of periods for the simulated series. Ignored if either
95\code{xreg} or \code{innov} are not \code{NULL}.}
96
97\item{seed}{Either \code{NULL} or an integer that will be used in a call to
98\code{\link[base]{set.seed}} before simulating the time series. The default,
99\code{NULL}, will not change the random generator state.}
100
101\item{future}{Produce sample paths that are future to and conditional on the
102data in \code{object}. Otherwise simulate unconditionally.}
103
104\item{bootstrap}{Do simulation using resampled errors rather than normally
105distributed errors or errors provided as \code{innov}.}
106
107\item{innov}{A vector of innovations to use as the error series. Ignored if
108\code{bootstrap==TRUE}. If not \code{NULL}, the value of \code{nsim} is set
109to length of \code{innov}.}
110
111\item{...}{Other arguments, not currently used.}
112
113\item{xreg}{New values of \code{xreg} to be used for forecasting. The value
114of \code{nsim} is set to the number of rows of \code{xreg} if it is not
115\code{NULL}.}
116
117\item{lambda}{Box-Cox transformation parameter. If \code{lambda="auto"},
118then a transformation is automatically selected using \code{BoxCox.lambda}.
119The transformation is ignored if NULL. Otherwise,
120data transformed before model is estimated.}
121}
122\value{
123An object of class "\code{ts}".
124}
125\description{
126Returns a time series based on the model object \code{object}.
127}
128\details{
129With \code{simulate.Arima()}, the \code{object} should be produced by
130\code{\link{Arima}} or \code{\link{auto.arima}}, rather than
131\code{\link[stats]{arima}}. By default, the error series is assumed normally
132distributed and generated using \code{\link[stats]{rnorm}}. If \code{innov}
133is present, it is used instead. If \code{bootstrap=TRUE} and
134\code{innov=NULL}, the residuals are resampled instead.
135
136When \code{future=TRUE}, the sample paths are conditional on the data. When
137\code{future=FALSE} and the model is stationary, the sample paths do not
138depend on the data at all. When \code{future=FALSE} and the model is
139non-stationary, the location of the sample paths is arbitrary, so they all
140start at the value of the first observation.
141}
142\examples{
143fit <- ets(USAccDeaths)
144plot(USAccDeaths, xlim=c(1973,1982))
145lines(simulate(fit, 36), col="red")
146
147}
148\seealso{
149\code{\link{ets}}, \code{\link{Arima}}, \code{\link{auto.arima}},
150\code{\link{ar}}, \code{\link{arfima}}, \code{\link{nnetar}}.
151}
152\author{
153Rob J Hyndman
154}
155\keyword{ts}
156