rolling_origin: Assessing forecasting accuracy with rolling origin

View source: R/rolling_origin.R

rolling_originR Documentation

Assessing forecasting accuracy with rolling origin

Description

It uses the model and the time series associated with a grnnForecast object to assess the forecasting accuracy of the model using the last h values of the time series to build test sets applying a rolling origin evaluation.

Usage

rolling_origin(grnnf, h = NULL, rolling = TRUE)

Arguments

grnnf

A grnnForecast object.

h

A positive integer. The forecast horizon. If NULL (the default) the prediction horizon of the gnnForecast object is used.

rolling

A logical. If TRUE (the default), forecasting horizons from 1 to h are used. Otherwise, only horizon h is used.

Details

This function assesses the forecast accuracy of the model used by the grnnForecast object. It uses h different test and training sets. The first test set consists of the last h values of the time series (the training set is formed by the previous values). The next test set consists of the last h - 1 values of the time series and so on (the last test set is formed by the last value of the time series).

Value

A list containing at least the following fields:

test_sets

a matrix containing the test sets used in the evaluation. Every row contains a different test set.

predictions

The predictions for the test sets.

errors

The errors for the test sets.

global_accu

Different measures of accuracy applied to all the errors.

h_accu

Different measures of accuracy applied to all the errors for every forecasting horizon.

Examples

pred <- grnn_forecasting(UKgas, h = 4, lags = 1:4)
ro <- rolling_origin(pred)
print(ro$global_accu)

tsfgrnn documentation built on March 31, 2023, 8:20 p.m.