The R package dejavu
provides efficient algorithms for forecasting with Similarity of a bunch of time series.
You can install dejavu
package from GitHub Repository with:
devtools::install_github("kl-lab/dejavu")
require("dejavu")
Using Reference data from M3 Competition (Download the repository to local first)
-
First download the reference data from GitHub to a folder e.g.
workspace
. Note that the reference git repository isgit-lfs
controlled, please use a recent version ofgit
andgit-lfs
software to clone it.cd workspace git clone https://github.com/kl-lab/dejavu-refdata.git
-
Now within R, you switch the work directory to
workspace
setwd('workspace') library(dtw) library(robustbase) library(forecast) fc_Simi <- Similarity(AirPassengers, fh = 20, LoadData = TRUE, path = NULL) fcs_result <- ts(fc_Simi$fcs, start = 1961, frequency = 12) PIL_result <- ts(fc_Simi$PIL, start = 1961, frequency = 12) PIU_result <- ts(fc_Simi$PIU, start = 1961, frequency = 12) autoplot(AirPassengers)+autolayer(fcs_result)+autolayer(PIL_result)+autolayer(PIU_result)
Assume you have created a user-defined reference in the folder my-dejavu-refdata
fc_Simi <- Similarity(AirPassengers, fh = 20, LoadData = FALSE, path = "my-dejavu-refdata")
- Yanfei Kang, Evangelos Spiliotis, Fotios Petropoulos, Nikolaos Athiniotis, Feng Li, Vassilios Assimakopoulos (2020). Déjà vu: A data-centric forecasting approach through time series cross-similarity Journal of Business Research. Working paper on arXiv.
This package is free and open source software, licensed under GPL-3.