rakshitha123 / TSForecasting

This repository contains the implementations related to the experiments of a set of publicly available datasets that are used in the time series forecasting research space.
https://forecastingdata.org/
Other
201 stars 43 forks source link

Why is arima giving an error when I use a subset of NN5 dataset without missing values? #6

Closed hkayabilisim closed 3 years ago

hkayabilisim commented 3 years ago

Here is the procedure I followed:

  1. Download nn5_daily_dataset_without_missing_values.tsf from Zenodo.
  2. Remove all the time series except the first and second one from TSF file and save as nn5_small.tsf. In the resulting TSF file there are two time series T1 and T2.
  3. Run "do_fixed_horizon_local_forecasting("nn5_small", "arima", "nn5_small.tsf","series_name", "start_timestamp")"

When I follow the above steps, I get the following error:

> do_fixed_horizon_local_forecasting("nn5_small", "arima", "nn5_small.tsf","series_name", "start_timestamp")
[1] "Started loading nn5_small"
[1] "started Forecasting"
[1] 1
[1] 2
[1] "Finished Forecasting"
Time difference of 1.184725 mins
The length of the provided data differs.
Length of holdout: 56
Length of forecast: 0
Error: Cannot proceed.
In addition: Warning messages:
1: The chosen seasonal unit root test encountered an error when testing for the first difference.
From stl(): NA/NaN/Inf in foreign function call (arg 1)
0 seasonal differences will be used. Consider using a different unit root test. 
2: The chosen seasonal unit root test encountered an error when testing for the first difference.
From stl(): NA/NaN/Inf in foreign function call (arg 1)
0 seasonal differences will be used. Consider using a different unit root test. 
3: In array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 'data' must be of a vector type, was 'NULL'

When I check the result file, I realized that there is no forecast for T1.

$ cat results/fixed_horizon_forecasts/nn5_small_arima.txt 
T1
T2,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771,12.9393424036281,15.3486394557823,18.75,29.6768707482993,30.7256235827664,16.7375283446712,12.046485260771

All other five methods (ets,ses,theta, tbats, and dhr_arima) work fine.

I wonder if this is an expected behaviour?

rakshitha123 commented 3 years ago

Hi,

I tried to reproduce your issue. But the code works fine for me after repeating the steps you mentioned. image

This is my "nn5_small.tsf" file: image

And the forecasts of both series are there in the forecasts file as well.

Can you please try again? Unfortunately, I can't do any alternations to my code, because I can't recreate your issue.

hkayabilisim commented 3 years ago

Hi,

I tried to debug the error. It appears that for the first time series T1, forecast function returns f=null (models/local_univariate_models.R line 57) since there is no exception, the null forecast propagates to the next steps. However for the second time series T2, that line throws an exception, and therefore the code switched to get_snaive_forecasts at line=61.

I guess there is a bug in one of the components I am using but it is very difficult to find it. Let me share the versions on my environment:

Mac OSX Mojave 10.14.6 R 3.6.3 GUI 1.70 El Capitan build (7735) --> What I see in R GUI R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night" --> what I see in R command line

List of R packages

  > ip = as.data.frame(installed.packages()[,c(1,3:4)])
  > ip = ip[is.na(ip$Priority),1:2,drop=FALSE]
  > ip
                          Package    Version
  anytime                 anytime      0.3.9
  askpass                 askpass        1.1
  assertthat           assertthat      0.2.1
  backports             backports      1.2.1
  base64enc             base64enc      0.1-3
  BH                           BH   1.75.0-0
  BiocManager         BiocManager    1.30.10
  BiocStyle             BiocStyle     2.14.4
  BiocVersion         BiocVersion     3.10.1
  bit                         bit      4.0.4
  bit64                     bit64      4.0.5
  blob                       blob      1.2.2
  bookdown               bookdown       0.18
  brew                       brew      1.0-6
  brio                       brio      1.1.2
  broom                     broom      0.7.9
  cachem                   cachem      1.0.6
  callr                     callr      3.7.0
  cellranger           cellranger      1.1.0
  chinamap               chinamap      0.2.0
  classInt               classInt      0.4-2
  cli                         cli      3.0.1
  clipr                     clipr      0.7.1
  colorspace           colorspace      1.4-1
  commonmark           commonmark        1.7
  cowplot                 cowplot      1.0.0
  cpp11                     cpp11      0.4.0
  crayon                   crayon      1.4.1
  credentials         credentials      1.3.1
  crosstalk             crosstalk      1.0.0
  curl                       curl        4.3
  data.table           data.table     1.12.8
  DBI                         DBI      1.1.0
  dbplyr                   dbplyr      2.1.1
  desc                       desc      1.3.0
  devtools               devtools      2.4.2
  diffobj                 diffobj      0.3.4
  digest                   digest     0.6.25
  downloader           downloader        0.4
  dplyr                     dplyr      1.0.7
  dtplyr                   dtplyr      1.1.0
  e1071                     e1071      1.7-3
  ellipsis               ellipsis      0.3.2
  evaluate               evaluate       0.14
  fansi                     fansi      0.4.1
  farver                   farver      2.0.3
  fastmap                 fastmap      1.0.1
  forcats                 forcats      0.5.1
  foreach                 foreach      1.5.1
  forecast               forecast       8.15
  fracdiff               fracdiff      1.5-1
  fs                           fs      1.5.0
  furrr                     furrr      0.2.3
  future                   future     1.22.1
  gargle                   gargle      1.2.0
  generics               generics      0.1.0
  gert                       gert      1.4.1
  ggplot2                 ggplot2      3.3.5
  ggplotify             ggplotify      0.0.4
  ggrepel                 ggrepel      0.8.2
  gh                           gh      1.3.0
  gitcreds               gitcreds      0.1.1
  glmnet                   glmnet      4.1-2
  globals                 globals     0.14.0
  glue                       glue      1.4.2
  googledrive         googledrive      2.0.0
  googlesheets4     googlesheets4      1.0.0
  greybox                 greybox      1.0.0
  gridGraphics       gridGraphics      0.5-0
  gtable                   gtable      0.3.0
  haven                     haven      2.4.3
  hexbin                   hexbin     1.28.1
  highr                     highr        0.8
  hms                         hms      1.1.0
  htmltools             htmltools      0.4.0
  htmlwidgets         htmlwidgets      1.5.1
  httpuv                   httpuv      1.5.2
  httr                       httr      1.4.2
  ids                         ids      1.0.1
  ini                         ini      0.3.1
  isoband                 isoband      0.2.0
  iterators             iterators     1.0.13
  jsonlite               jsonlite      1.7.2
  knitr                     knitr       1.28
  labeling               labeling        0.3
  lamW                       lamW      2.1.0
  later                     later      1.0.0
  lazyeval               lazyeval      0.2.2
  lifecycle             lifecycle      1.0.0
  listenv                 listenv      0.8.0
  lmtest                   lmtest     0.9-37
  lubridate             lubridate     1.7.10
  magick                   magick        2.3
  magrittr               magrittr      2.0.1
  mapproj                 mapproj      1.2.7
  maps                       maps      3.3.0
  markdown               markdown        1.1
  memoise                 memoise      2.0.0
  mime                       mime        0.9
  modelr                   modelr      0.1.8
  munsell                 munsell      0.5.0
  nCov2019               nCov2019      0.3.3
  nloptr                   nloptr    1.2.2.2
  openssl                 openssl      1.4.1
  parallelly           parallelly     1.28.1
  pillar                   pillar      1.6.2
  pinyin                   pinyin      1.1.6
  pkgbuild               pkgbuild      1.2.0
  pkgconfig             pkgconfig      2.0.3
  pkgload                 pkgload      1.2.2
  plotly                   plotly      4.9.2
  pracma                   pracma      2.3.3
  praise                   praise      1.0.0
  prettyunits         prettyunits      1.1.1
  processx               processx      3.5.2
  progress               progress      1.2.2
  promises               promises      1.1.0
  ps                           ps      1.6.0
  purrr                     purrr      0.3.4
  quadprog               quadprog      1.5-8
  quantmod               quantmod     0.4-16
  R6                           R6      2.4.1
  rappdirs               rappdirs      0.3.3
  Rcatch22               Rcatch22     0.1.12
  rcmdcheck             rcmdcheck      1.3.3
  RColorBrewer       RColorBrewer      1.1-2
  Rcpp                       Rcpp      1.0.3
  RcppArmadillo     RcppArmadillo 0.10.6.0.0
  RcppParallel       RcppParallel      5.1.4
  RcppRoll               RcppRoll      0.3.0
  readr                     readr      2.0.1
  readxl                   readxl      1.3.1
  rematch                 rematch      1.0.1
  rematch2               rematch2      2.1.2
  remotes                 remotes      2.4.0
  reprex                   reprex      2.0.1
  rlang                     rlang     0.4.11
  rmarkdown             rmarkdown        2.1
  roxygen2               roxygen2      7.1.2
  rprojroot             rprojroot      2.0.2
  rstudioapi           rstudioapi       0.13
  rvcheck                 rvcheck      0.1.8
  rversions             rversions      2.1.1
  rvest                     rvest      1.0.1
  scales                   scales      1.1.0
  selectr                 selectr      0.4-2
  sessioninfo         sessioninfo      1.1.1
  sf                           sf      0.8-1
  shape                     shape      1.4.6
  shiny                     shiny      1.4.0
  shinyBS                 shinyBS       0.61
  smooth                   smooth      3.1.2
  sourcetools         sourcetools      0.1.7
  sp                           sp      1.4-1
  splitstackshape splitstackshape      1.4.8
  statmod                 statmod     1.4.36
  stringi                 stringi      1.4.6
  stringr                 stringr      1.4.0
  sys                         sys        3.3
  testthat               testthat      3.0.4
  texreg                   texreg     1.37.5
  tibble                   tibble      3.1.4
  tidyr                     tidyr      1.1.3
  tidyselect           tidyselect      1.1.1
  tidyverse             tidyverse      1.3.1
  timeDate               timeDate   3043.102
  tinytex                 tinytex       0.20
  tseries                 tseries    0.10-47
  tsfeatures           tsfeatures      1.0.2
  tsibble                 tsibble      1.0.1
  TTR                         TTR     0.23-6
  tzdb                       tzdb      0.1.2
  units                     units      0.6-5
  urca                       urca      1.3-0
  usethis                 usethis      2.0.1
  utf8                       utf8      1.1.4
  uuid                       uuid      0.1-4
  vctrs                     vctrs      0.3.8
  viridisLite         viridisLite      0.3.0
  vroom                     vroom      1.5.5
  waldo                     waldo      0.3.1
  whisker                 whisker        0.4
  withr                     withr      2.4.2
  xfun                       xfun       0.12
  xml2                       xml2      1.3.2
  xopen                     xopen      1.0.0
  xtable                   xtable      1.8-4
  xts                         xts     0.12-0
  yaml                       yaml      2.2.1
  zip                         zip      2.2.0
  zoo                         zoo      1.8-7