tidyverts / fabletools

General fable features useful for extension packages
http://fabletools.tidyverts.org/
89 stars 31 forks source link

Back transformation of multi-step fitted values #300

Closed robjhyndman closed 3 years ago

robjhyndman commented 3 years ago
library(fable)
#> Loading required package: fabletools

fit <- USAccDeaths %>%
  as_tsibble() %>%
  model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) 

fitted(fit, h=1) %>% tail()
#> # A tsibble: 6 x 3 [1M]
#> # Key:       .model [1]
#>   .model    index .fitted
#>   <chr>     <mth>   <dbl>
#> 1 arima  1978 Jul  10462.
#> 2 arima  1978 Aug   9545.
#> 3 arima  1978 Sep   8575.
#> 4 arima  1978 Oct   9298.
#> 5 arima  1978 Nov   8608.
#> 6 arima  1978 Dec   9011.
fitted(fit, h=2) %>% tail()
#> # A tsibble: 6 x 3 [1M]
#> # Key:       .model [1]
#>   .model    index value
#>   <chr>     <mth> <dbl>
#> 1 arima  1978 Jul  9.26
#> 2 arima  1978 Aug  9.16
#> 3 arima  1978 Sep  9.04
#> 4 arima  1978 Oct  9.11
#> 5 arima  1978 Nov  9.07
#> 6 arima  1978 Dec  9.10

Created on 2020-12-27 by the reprex package (v0.3.0)

Also column names for h>1 use original series name rather than .fitted.