tune_grid {utsf}R Documentation

Estimate the forecast accuracy of a model on a time series according to a grid of parameters

Description

It uses an object of class utsf to asses the forecasting accuracy of its associated model on its associated time series applying rolling origin evaluation according to different configurations of model parameters.

Usage

tune_grid(
  model,
  h,
  tuneGrid,
  type = c("normal", "minimum"),
  size = NULL,
  prop = NULL
)

Arguments

model

An object of class utsf with a model trained with a time series.

h

A positive integer. The forecasting horizon.

tuneGrid

A data frame with possible tuning values. The columns are named as the tuning parameters.

type

A string. Possible values are "normal" (the default) and "minimum". See the vignette utsf for an explanation of both ways of evaluating forecast accuracy.

size

An integer. It is the size of the test set (how many of the last observations of the time series are used as test set). It can only be used when the type parameter is "normal". By default, it is the length of the forecasting horizon.

prop

A numeric value in the range (0, 1). It is the proportion of the time series used as test set. It can only be used when the type parameter is "normal".

Details

The estimation of forecast accuracy is done with the efa() function. The best combination of parameters is used to train the model with all the historical values of the time series and forecast h values ahead.

Value

A list with three components:

tuneGrid

A data frame with the different combination of parameters and the estimated forecast accuracy of a model trained with those parameters.

best

The best combination of parameters according to root mean squared error.

forecast

An object of class utsf_forecast with the forecast for horizon h using the best estimated combination of parameters.

Examples

m <- create_model(UKgas, lags = 1:4, method = "knn")
tune_grid(m, h = 4, tuneGrid = expand.grid(k = 1:7), type = "normal", size = 8)

[Package utsf version 1.3.0 Index]