unpack_hilo no longer seems to be working. After fitting a model I get the error
Error in tidyr::unpack()
:
! Can't rename variables in this context.
After running the code
fit<-ts_data_full%>%model(ARIMA(Total_Data~pdq(2,1,1)+PDQ(0,1,1)))
fc.2<-fit%>%forecast(h=12)%>%hilo(level=80)%>%unpack_hilo("80%")
The model object is fine. Passing the model object to hilo() produces no errors. Generating a graph of the model produces no errors.
However, unpack_hilo() no longer works since the last time I ran it in fall 22'.
This is due to a change in tidyr v1.3.0, reported here: unpack_hilo() not working with tidyr v1.3.0 · Issue #376 · tidyverts/fabletools · GitHub
Instead of using unpack_hilo()
, you can simply use $
notation to refer to the upper and lower limits like this:
library(fpp3)
#> ── Attaching packages ─────────────────────────────────────── fpp3 0.4.0.9000 ──
#> ✔ tibble 3.1.8 ✔ tsibble 1.1.3
#> ✔ dplyr 1.1.0 ✔ tsibbledata 0.4.1
#> ✔ tidyr 1.3.0 ✔ feasts 0.3.0
#> ✔ lubridate 1.9.1 ✔ fable 0.3.2
#> ✔ ggplot2 3.4.0 ✔ fabletools 0.3.2.9000
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> ✖ lubridate::date() masks base::date()
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ tsibble::intersect() masks base::intersect()
#> ✖ tsibble::interval() masks lubridate::interval()
#> ✖ dplyr::lag() masks stats::lag()
#> ✖ tsibble::setdiff() masks base::setdiff()
#> ✖ tsibble::union() masks base::union()
as_tsibble(lynx) |>
model(ARIMA(value)) |>
forecast(h=10) |>
hilo(level=80) |>
mutate(
lower = `80%`$lower,
upper = `80%`$upper
)
#> # A tsibble: 10 x 7 [1Y]
#> # Key: .model [1]
#> .model index value .mean `80%` lower upper
#> <chr> <dbl> <dist> <dbl> <hilo> <dbl> <dbl>
#> 1 ARIMA(val… 1935 N(2990, 761965) 2990. [ 1871.2360, 4108.585]80 1871. 4109.
#> 2 ARIMA(val… 1936 N(2093, 1751057) 2093. [ 397.6326, 3789.323]80 398. 3789.
#> 3 ARIMA(val… 1937 N(1307, 2e+06) 1307. [ -516.0692, 3130.687]80 -516. 3131.
#> 4 ARIMA(val… 1938 N(856, 2e+06) 856. [ -967.5900, 2680.057]80 -968. 2680.
#> 5 ARIMA(val… 1939 N(781, 2121434) 781. [-1086.0147, 2647.182]80 -1086. 2647.
#> 6 ARIMA(val… 1940 N(983, 2312638) 983. [ -965.9078, 2931.896]80 -966. 2932.
#> 7 ARIMA(val… 1941 N(1306, 2455486) 1306. [ -702.5723, 3313.808]80 -703. 3314.
#> 8 ARIMA(val… 1942 N(1602, 2500687) 1602. [ -424.3716, 3628.807]80 -424. 3629.
#> 9 ARIMA(val… 1943 N(1783, 2501627) 1783. [ -244.0798, 3809.860]80 -244. 3810.
#> 10 ARIMA(val… 1944 N(1826, 2512051) 1826. [ -205.6736, 3856.705]80 -206. 3857.
Created on 2023-02-06 with reprex v2.0.2
That works. Thank you for the reply.
system
Closed
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.