Description
Time Series Forecasting Using Nearest Neighbors.
Description
Allows forecasting time series using nearest neighbors regression Francisco Martinez, Maria P. Frias, Maria D. Perez-Godoy and Antonio J. Rivera (2019) <doi:10.1007/s10462-017-9593-z>. When the forecasting horizon is higher than 1, two multi-step ahead forecasting strategies can be used. The model built is autoregressive, that is, it is only based on the observations of the time series. The nearest neighbors used in a prediction can be consulted and plotted.
README.md
tsfknn
The goal of tsfknn is to forecast time series using KNN regression
Installation
You can install tsfknn from github with:
# install.packages("devtools")
devtools::install_github("franciscomartinezdelrio/tsfknn")
Example
This is a basic example which shows you how to forecast with tsfknn:
library(tsfknn)
pred <- knn_forecasting(USAccDeaths, h = 12, k = 3)
pred$prediction # To see a time series with the forecasts
plot(pred) # To see a plot with the forecast
library(ggplot2)
autoplot(pred, highlight = "neighbors") # To see the nearest neighbors