| forecast.stl | R Documentation |
Forecasts of STL objects are obtained by applying a non-seasonal forecasting method to the seasonally adjusted data and re-seasonalizing using the last year of the seasonal component.
## S3 method for class 'stl'
forecast(
object,
method = c("ets", "arima", "naive", "rwdrift"),
etsmodel = "ZZN",
forecastfunction = NULL,
h = frequency(object$time.series) * 2,
level = c(80, 95),
fan = FALSE,
lambda = NULL,
biasadj = FALSE,
xreg = NULL,
newxreg = NULL,
allow.multiplicative.trend = FALSE,
...
)
## S3 method for class 'stlm'
forecast(
object,
h = 2 * object$m,
level = c(80, 95),
fan = FALSE,
lambda = object$lambda,
biasadj = attr(lambda, "biasadj"),
newxreg = NULL,
allow.multiplicative.trend = FALSE,
...
)
stlf(
y,
h = frequency(x) * 2,
s.window = 7 + 4 * seq(6),
t.window = NULL,
robust = FALSE,
lambda = NULL,
biasadj = FALSE,
x = y,
...
)
object |
An object of class |
method |
Method to use for forecasting the seasonally adjusted series. |
etsmodel |
The ets model specification passed to
|
forecastfunction |
An alternative way of specifying the function for
forecasting the seasonally adjusted series. If |
h |
Number of periods for forecasting. If |
level |
Confidence levels for prediction intervals. |
fan |
If |
lambda |
Box-Cox transformation parameter. If |
biasadj |
Use adjusted back-transformed mean for Box-Cox
transformations. If transformed data is used to produce forecasts and fitted
values, a regular back transformation will result in median forecasts. If
biasadj is |
xreg |
Historical regressors to be used in
|
newxreg |
Future regressors to be used in |
allow.multiplicative.trend |
If |
... |
Other arguments passed to |
y |
a numeric vector or univariate time series of class |
s.window |
Either the character string |
t.window |
A number to control the smoothness of the trend. See
|
robust |
If |
x |
Deprecated. Included for backwards compatibility. |
forecast.stlm forecasts the seasonally adjusted data, then
re-seasonalizes the results by adding back the last year of the estimated
seasonal component.
stlf combines stlm() and forecast.stlm. It takes a
ts argument, applies an STL decomposition, models the seasonally
adjusted data, reseasonalizes, and returns the forecasts. However, it allows
more general forecasting methods to be specified via
forecastfunction.
forecast.stl is similar to stlf except that it takes the STL
decomposition as the first argument, instead of the time series.
Note that the prediction intervals ignore the uncertainty associated with the seasonal component. They are computed using the prediction intervals from the seasonally adjusted series, which are then reseasonalized using the last year of the seasonal component. The uncertainty in the seasonal component is ignored.
The forecasting method for the seasonally adjusted data can be specified in
stlf and forecast.stl using either method or
forecastfunction. The method argument provides a shorthand way
of specifying forecastfunction for a few special cases. More
generally, forecastfunction can be any function with first argument a
ts object, and other h and level, which returns an
object of class forecast(). For example,
forecastfunction = thetaf uses the thetaf() function for
forecasting the seasonally adjusted series.
stlm returns an object of class stlm. The other
functions return objects of class forecast.
There are many methods for working with forecast() objects
including summary to obtain and print a summary of the results, while
plot produces a plot of the forecasts and prediction intervals. The
generic accessor functions fitted.values and residuals extract
useful features.
Rob J Hyndman
stats::stl(), forecast.ets(), forecast.Arima().
tsmod <- stlm(USAccDeaths, modelfunction = ar)
plot(forecast(tsmod, h = 36))
decomp <- stl(USAccDeaths, s.window = "periodic")
plot(forecast(decomp))
plot(stlf(AirPassengers, lambda = 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.