Learn R Programming

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

347

Version

0.6.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Francisco Martinez

Last Published

December 20th, 2023

Functions in tsfknn (0.6.0)

knn_forecasting

Time series forecasting using KNN regression
n_training_examples

Number of training examples
plot.knnForecastRO

Plot a prediction of a test set
rolling_origin

Assessing forecasting accuracy with rolling origin
tsfknn-package

tsfknn: Time Series Forecasting Using Nearest Neighbors
autoplot.knnForecast

Create a ggplot object from a knnForecast object
knn_examples

Examples of the model associated with a prediction
nearest_neighbors

Nearest neighbors associated with predictions
predict.knnForecast

Predict method for KNN models for time series forecasting.