Time Series Forecasting Using Nearest Neighbors

Allows to forecast time series using nearest neighbors regression Francisco Martinez, Maria P. Frias, Maria D. Perez-Godoy and Antonio J. Rivera (2017) . 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.


The goal of tsfknn is to forecast time series using KNN regression

Installation

You can install tsfknn from 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

News

tsfknn 0.2.0

  • summary and print.summary methods are added for "knnForecast" objects
  • String parameters are processed with math.arg
  • Fix calculation of how many KNN examples has the model in knn_forecasting
  • Weighted combination of the targets of nearest neighbors is implemented
  • A function that computes the number of training instances that would have a model has been added

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("tsfknn")

0.3.0 by Francisco Martinez, 6 months ago


https://github.com/franciscomartinezdelrio/tsfknn


Report a bug at https://github.com/franciscomartinezdelrio/tsfknn/issues


Browse source code at https://github.com/cran/tsfknn


Authors: Francisco Martinez [aut, cre]


Documentation:   PDF Manual  


Task views: Time Series Analysis


GPL-2 license


Imports ggplot2, graphics, stats, utils

Suggests knitr, rmarkdown, testthat


See at CRAN