Learn R Programming

narfima (version 0.1.0)

forecast_narfima_class: Forecasting from NARFIMA-class Models

Description

This function produces forecasts from fitted models of class narfima, including NARFIMA, NARIMA, NBSTS, and NNaive. Multi-step forecasts are computed recursively. Prediction intervals can also be obtained through simulation.

Usage

forecast_narfima_class(
  object,
  h = ifelse(object$m > 1, 2 * object$m, 10),
  PI = FALSE,
  level = 80,
  fan = FALSE,
  bootstrap = FALSE,
  npaths = 1000,
  innov = NULL,
  xreg = NULL,
  lambda = object$lambda,
  lambdae = object$lambdae,
  ...
)

Value

An object of class "forecast" containing:

mean

The point forecasts.

lower

The lower bounds of the prediction intervals.

upper

The upper bounds of the prediction intervals.

level

The confidence level for the prediction intervals.

model

The fitted NARFIMA model.

series

The name of the input series.

method

A string describing the model parameters.

y

The input time series.

e

The transformed residual series

Arguments

object

An object of class "narfima".

h

Number of periods to forecast. If xreg is provided, h is ignored and the forecast horizon is determined by the number of rows in xreg.

PI

Logical value indicating whether to compute prediction intervals (default is FALSE).

level

Confidence level for prediction intervals (default is 80), ignored when PI = FALSE.

fan

If TRUE (default is FALSE), level is set to seq(51, 99, by = 3). This is suitable for fan plots.

bootstrap

Logical value indicating whether to use bootstrapping for prediction intervals (default is FALSE), ignored when PI = FALSE.

npaths

Number of simulation paths for prediction intervals (default is 1000), ignored when PI = FALSE.

innov

An optional vector of innovations to use for simulating future values (default is NULL). If NULL and PI = TRUE, random innovations are generated.

xreg

An optional matrix or data frame of exogenous variables to be used in forecasting (default is NULL).

lambda

Numeric value for the Box-Cox transformation parameter of y (default is taken from the fitted model, i.e., object$lambda).

lambdae

Numeric value for the Box-Cox transformation parameter of er (default is taken from the fitted model, i.e., object$lambdae).

...

Additional arguments passed to pred_interval_narfima.

Examples

Run this code
h <- 3

data <- EuStockMarkets[(nrow(EuStockMarkets) - 83):nrow(EuStockMarkets), 3]

train <- data[1:(length(data) - h)]
test <- data[(length(data) - h + 1):length(data)]

narfima_model <- auto_narfima(train)
narfima_forecast <- forecast_narfima_class(narfima_model, h)

Run the code above in your browser using DataLab