forecast.varstan: Forecasting varstan objects

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/forecast.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'varstan'
forecast(
  object,
  h = 10,
  probs = c(0.8, 0.9),
  xreg = NULL,
  robust = FALSE,
  draws = 1000,
  seed = NULL,
  ...
)

Arguments

object

a time series or varstan model for which forecasts are required.

h

Number of periods for forecasting.

probs

A numerical vector p (0 < p < 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)).

xreg

Optionally, a numerical matrix of external regressors, which must have the same number of rows as ts. It should not be a data frame.

robust

A boolean for obtain the robust estimation. The default

draws

An integer indicating the number of draws to return. The default number of draws is 1000.

seed

An optional seed to use.

...

Further arguments passed to posterior_predict.

Details

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.

Value

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:

model

A list containing information about the fitted model

method

The name of the forecasting method as a character string

mean

Point forecasts as a time series

lower

Lower limits for prediction intervals

upper

Upper limits for prediction intervals

level

The confidence values associated with the prediction intervals

x

The original time series (either object itself or the time series used to create the model stored as object).

residuals

Residuals from the fitted model. For models with additive errors, the residuals will be x minus the fitted values.

fitted

Fitted values (one-step forecasts)

Author(s)

Asael Alonzo Matamoros.

See Also

The "forecast" methods of the forecast package.

Examples

1
2
 fit = auto.sarima(ts = birth,iter = 500,chains = 1)
 fc = forecast(fit,h = 12)

bayesforecast documentation built on June 17, 2021, 5:14 p.m.