fable Prophet giving null model

38 Views Asked by At

this is my dataset

modi_delhi_tsib
# A tsibble: 6,576 x 21 [4h] <UTC>
   `Time Periods`      PM2.5    NO   NO2   NOx   NH3   SO2    CO Ozone Benzene Toluene  Temp    RH    WS    WD     SR    BP    AT    RF `TOT-RF`      VWS
   <dttm>              <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>   <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
 1 2020-01-01 00:00:00  549. 181.   91.2 188.   79.7  10.2 3.52   23.4   NA       NA    7.75  93.4 0.254 168.    9.05  921.  6.75     0        0 -0.00947
 2 2020-01-01 04:00:00  435. 194.   79.7 203.   66.3  11.6 3.46   29.3    9.83    NA    7.49  95.3 0.233 192.   20.7   932.  5.99     0        0 -0.0125 
 3 2020-01-01 08:00:00  453. 112.  122.  154.   74.4  10.6 2.46   30.2    9.09    NA    9.45  67.7 0.805 110.  258.    918. 11.3      0        0 -0.00434
 4 2020-01-01 12:00:00  187.  56.9 114.   91.5  74.4  12.2 1.41   30.5    3.88   104.  11.3   51.0 1.16   96.5 271.    904. 15.6      0        0  0.0549 
 5 2020-01-01 16:00:00  263.  77.4 124.  117.   74.4  13.3 2.69   18.0    5.61    96.7 10.2   69.7 0.375 157.   41.1   916. 12.5      0        0  0.0547 
 6 2020-01-01 20:00:00  725.  77.4 124.  117.   74.4  20.8 3.12   15.7    5.61   182.   8.76  89.1 0.220 185.    8.82  926.  9.50     0        0  0.0197 
 7 2020-01-02 00:00:00  541.  77.4 124.  117.   74.4  16.1 5.31   16.6    5.61   181.   8.4   92.3 0.219 183.    6.05  917.  8.52     0        0  0.0152 
 8 2020-01-02 04:00:00  428.  77.4 124.  117.   74.4  13.8 3.13   19.0    5.61   130.   8.14  94.6 0.247 186.   16.3   929.  7.62     0        0  0.0171 
 9 2020-01-02 08:00:00  383. 127.  126.  164.   74.4  22.3 1.97   23.8    7.40    92.8 10.4   68.9 0.494 145.  269.    923. 13.3      0        0  0.0359 
10 2020-01-02 12:00:00  166.  53.6 113.   86.6  74.4  16.9 0.975  28.2    4.26    26.0 11.9   46.8 0.755  80.0 268.    895. 17.9      0        0  0.0756 
# ℹ 6,566 more rows
# ℹ Use `print(n = ...)` to see more rows

I want to build a prophet model to forecast the PM2.5 variable in my dataset but on using the prophet function on running the following code or on changing the formulas I am getting a null model

modi_delhi_tsib |>
+     model(prophet(PM2.5~season("year", 4, type = "multiplicative")))
# A mable: 1 x 1
  `prophet(PM2.5 ~ season("year", 4, type = "multiplicative"))`
                                                        <model>
1                                                  <NULL model>
Warning message:
1 error encountered for prophet(PM2.5 ~ season("year", 4, type = "multiplicative"))
[1] 
 
> modi_delhi_tsib |>
+     model(prophet(PM2.5))
# A mable: 1 x 1
  `prophet(PM2.5)`
           <model>
1     <NULL model>
Warning message:
1 error encountered for prophet(PM2.5)
[1]  

how can I resolve this? Thanks for the help.

This is my session info :-

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default


locale:
[1] LC_COLLATE=English_India.utf8  LC_CTYPE=English_India.utf8    LC_MONETARY=English_India.utf8 LC_NUMERIC=C                   LC_TIME=English_India.utf8    

time zone: Asia/Calcutta
tzcode source: internal

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] fable_0.3.3              feasts_0.3.1             tsibbledata_0.4.1        fpp3_0.5                 tsibble_1.1.3            fable.prophet_0.1.0.9000
 [7] fabletools_0.3.3         Rcpp_1.0.11              hms_1.1.3                patchwork_1.1.3          stringdist_0.9.10        YaleToolkit_4.2.3       
[13] lubridate_1.9.3          forcats_1.0.0            stringr_1.5.0            dplyr_1.1.3              purrr_1.0.2              readr_2.1.4             
[19] tidyr_1.3.0              tibble_3.2.1             ggplot2_3.4.3            tidyverse_2.0.0         

loaded via a namespace (and not attached):
 [1] gtable_0.3.4         anytime_0.3.9        QuickJSR_1.0.6       xfun_0.40            processx_3.8.2       inline_0.3.19        corrr_0.4.4         
 [8] callr_3.7.3          tzdb_0.4.0           vctrs_0.6.3          tools_4.3.1          ps_1.7.5             generics_0.1.3       stats4_4.3.1        
[15] parallel_4.3.1       fansi_1.0.4          highr_0.10           pkgconfig_2.0.3      prophet_1.0          distributional_0.3.2 RcppParallel_5.1.7  
[22] lifecycle_1.0.3      compiler_4.3.1       farver_2.1.1         munsell_0.5.0        codetools_0.2-19     pillar_1.9.0         crayon_1.5.2        
[29] ellipsis_0.3.2       StanHeaders_2.26.28  iterators_1.0.14     foreach_1.5.2        rstan_2.26.23        tidyselect_1.2.0     digest_0.6.33       
[36] stringi_1.7.12       colorspace_2.1-0     cli_3.6.1            magrittr_2.0.3       loo_2.6.0            pkgbuild_1.4.2       utf8_1.2.3          
[43] withr_2.5.1          rappdirs_0.3.3       prettyunits_1.2.0    scales_1.2.1         timechange_0.2.0     matrixStats_1.0.0    gridExtra_2.3       
[50] progressr_0.14.0     evaluate_0.22        knitr_1.44           rlang_1.1.1          glue_1.6.2           jsonlite_1.8.7       rstudioapi_0.15.0   
[57] R6_2.5.1    
1

There are 1 best solutions below

0
Mitchell O'Hara-Wild On

There was an issue with how the {fable.prophet} package was handling the space in the index variable's name. It has been fixed in https://github.com/mitchelloharawild/fable.prophet/commit/3c458270e1904c6b355ed09bd150071120fd501d

To resolve the issue you can install the development version of the package with

# install.packages("remotes")
remotes::install_github("mitchelloharawild/fable.prophet")