predict.knnForecast | R Documentation |

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

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

`object` |
a |

`h` |
an integer. The forecasting horizon. |

`...` |
further arguments passed to or from other methods. |

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

a `knnForecast`

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

for the structure of `knnForecast`

objects.

```
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
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.