Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multistep fitted values returning only NAs #302

Closed
robjhyndman opened this issue Jan 19, 2021 · 2 comments
Closed

Multistep fitted values returning only NAs #302

robjhyndman opened this issue Jan 19, 2021 · 2 comments

Comments

@robjhyndman
Copy link
Member

This was working recently.

library(fpp3)
#> ── Attaching packages ─────────────────────────────────────── fpp3 0.3.0.9000 ──
#> ✓ tibble      3.0.5          ✓ tsibble     0.9.3     
#> ✓ dplyr       1.0.3          ✓ tsibbledata 0.2.0     
#> ✓ tidyr       1.1.2          ✓ feasts      0.1.6.9000
#> ✓ lubridate   1.7.9.2        ✓ fable       0.2.1     
#> ✓ ggplot2     3.3.3
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> x lubridate::date()   masks base::date()
#> x dplyr::filter()     masks stats::filter()
#> x tsibble::interval() masks lubridate::interval()
#> x dplyr::lag()        masks stats::lag()
auscafe <- aus_retail %>%
  filter(stringr::str_detect(Industry, "Takeaway")) %>%
  summarise(Turnover = sum(Turnover))
cafe_fit <- auscafe %>%
  model(ARIMA(log(Turnover)))
cafe_fit
#> # A mable: 1 x 1
#>      `ARIMA(log(Turnover))`
#>                     <model>
#> 1 <ARIMA(1,1,0)(2,1,2)[12]>
fitted(cafe_fit, h = 12) %>%
  pull(.fitted)
#>   [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#>  [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#>  [51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#>  [76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [101] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [126] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [151] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [176] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [201] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [226] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [251] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [276] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [301] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [326] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [351] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [376] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [401] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
#> [426] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA

Created on 2021-01-20 by the reprex package (v0.3.0)

Session info
sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.10
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
#>  [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
#>  [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices datasets  utils     methods   base     
#> 
#> other attached packages:
#>  [1] fable_0.2.1       feasts_0.1.6.9000 fabletools_0.3.0  tsibbledata_0.2.0
#>  [5] tsibble_0.9.3     ggplot2_3.3.3     lubridate_1.7.9.2 tidyr_1.1.2      
#>  [9] dplyr_1.0.3       tibble_3.0.5      fpp3_0.3.0.9000  
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.6                urca_1.3-0               
#>  [3] progressr_0.7.0           pillar_1.4.7             
#>  [5] compiler_4.0.3            highr_0.8                
#>  [7] tools_4.0.3               digest_0.6.27            
#>  [9] lattice_0.20-41           nlme_3.1-151             
#> [11] anytime_0.3.9             evaluate_0.14            
#> [13] lifecycle_0.2.0           gtable_0.3.0             
#> [15] pkgconfig_2.0.3           rlang_0.4.10             
#> [17] cli_2.2.0                 DBI_1.1.1                
#> [19] rstudioapi_0.13           yaml_2.2.1               
#> [21] xfun_0.20                 withr_2.4.0              
#> [23] stringr_1.4.0             knitr_1.30               
#> [25] generics_0.1.0            vctrs_0.3.6              
#> [27] grid_4.0.3                tidyselect_1.1.0         
#> [29] glue_1.4.2                R6_2.5.0                 
#> [31] fansi_0.4.2               distributional_0.2.1.9000
#> [33] rmarkdown_2.6             farver_2.0.3             
#> [35] purrr_0.3.4               magrittr_2.0.1           
#> [37] scales_1.1.1              ellipsis_0.3.1           
#> [39] htmltools_0.5.1           assertthat_0.2.1         
#> [41] colorspace_2.0-0          renv_0.12.5              
#> [43] utf8_1.1.4                stringi_1.5.3            
#> [45] munsell_0.5.0             crayon_1.3.4
@mitchelloharawild
Copy link
Member

hfitted(<ARIMA>) is available in fable >= v0.2.1.9000, so the solution here is to update fable.
It should fall back to a repeated refit(<ARIMA>) and forecast(<ARIMA>), but seemingly this is giving NA h-step fits. I believe this is due to unrelated changes to how transformations are handled and response variables are represented.

@mitchelloharawild
Copy link
Member

The fallback method should now work with transformed responses. The result seems pretty similar between the fallback method and custom hfitted method for ARIMA.

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants