forecast
is a generic function for forecasting from time series or
varstan models. The function invokes particular methods which
depend on the class of the first argument.
# S3 method for varstan
forecast(
object,
h = 10,
probs = c(0.8, 0.9),
xreg = NULL,
robust = FALSE,
draws = 1000,
seed = NULL,
...
)
a time series or varstan model for which forecasts are required.
Number of periods for forecasting.
A numerical vector \(p \in (0,1)\) indicating the desired
probability mass to include in the intervals. The default is to report
90%
and 80%
intervals (level=c(0.8,0.9)
).
Optionally, a numerical matrix of external regressors, which must have the same number of rows as ts. It should not be a data frame.
A boolean for obtain the robust estimation. The default
An integer indicating the number of draws to return. The default number of draws is 1000.
An optional seed
to use.
Further arguments passed to posterior_predict
.
An object of class "forecast
".
The function summary
is used to obtain and print a summary of the
results, while the function plot
produces a plot of the forecasts and
prediction intervals.
The generic accessors functions fitted.values
and residuals
extract various useful features of the value returned by
forecast$model
.
An object of class "forecast"
is a list usually containing at least
the following elements:
A list containing information about the fitted model
The name of the forecasting method as a character string
Point forecasts as a time series
Lower limits for prediction intervals
Upper limits for prediction intervals
The confidence values associated with the prediction intervals
The original time series
(either object
itself or the time series used to create the model
stored as object
).
Residuals from the fitted model. For models with additive errors, the residuals will be x minus the fitted values.
Fitted values (one-step forecasts)
If model=NULL
,the function forecast.ts
makes forecasts
using ets
models (if the data are non-seasonal or the seasonal
period is 12 or less) or stlf
(if the seasonal period is 13 or
more).
If model
is not NULL
, forecast.ts
will apply the
model
to the object
time series, and then generate forecasts
accordingly.
The "forecast"
methods of the forecast package.
# NOT RUN {
fit = auto.sarima(ts = birth,iter = 500,chains = 1)
fc = forecast(fit,h = 12)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab