predict.knnForecast function

Predict method for KNN models for time series forecasting.

Predict method for KNN models for time series forecasting.

Predicted values based on a KNN model for time series forecasting.

## S3 method for class 'knnForecast' predict(object, h, ...)

Arguments

  • object: a knnForecast object obtained by a call to the knn_forecasting function.
  • h: an integer. The forecasting horizon.
  • ...: further arguments passed to or from other methods.

Returns

a knnForecast object with the prediction and information about the KNN model, see the documentation of knn_forecasting

for the structure of knnForecast objects.

Details

If the models uses the MIMO strategy for multiple-step ahead prediction, the forecasting horizon is fixed to the model forecasting horizon.

Examples

pred <- knn_forecasting(UKgas, h = 4, k = 1, msas = "recursive") new_pred <- predict(pred, h = 6) print(new_pred$prediction) plot(new_pred) # To see a plot with the forecast