Learn R Programming

⚠️There's a newer version (0.6.0) of this package.Take me there.

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

Copy Link

Version

Install

install.packages('tsfknn')

Monthly Downloads

405

Version

0.5.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Francisco Martinez

Last Published

April 5th, 2021

Functions in tsfknn (0.5.0)

knn_forecasting

Time series forecasting using KNN regression
nearest_neighbors

Nearest neighbors associated with predictions
autoplot.knnForecast

Create a ggplot object from a knnForecast object
predict.knnForecast

Predict method for KNN models for time series forecasting.
rolling_origin

Assessing forecasting accuracy with rolling origin
plot.knnForecastRO

Plot a prediction of a test set
tsfknn

tsfknn: A package for time series forecasting using KNN regression.
n_training_examples

Number of training examples
knn_examples

Examples of the model associated with a prediction