mitchelloharawild / distributional

Vectorised distributions for R
https://pkg.mitchelloharawild.com/distributional
GNU General Public License v3.0
94 stars 15 forks source link

error with autoplot() of forecasts #43

Closed EconProf closed 3 years ago

EconProf commented 3 years ago

Today's version of distributional appears to have a problem with autoplot() for forecasts. I think that d8a3e2d worked OK. As usual, operator error may be the cause.

library(fpp3)
#> Warning: replacing previous import 'vctrs::data_frame' by 'tibble::data_frame'
#> when loading 'dplyr'

fit <- us_change %>%
  model(ARIMA(Consumption))
(fcst <- fit %>% forecast(h = 4))
#> # A fable: 4 x 4 [1Q]
#> # Key:     .model [1]
#>   .model             Quarter   Consumption .mean
#>   <chr>                <qtr>        <dist> <dbl>
#> 1 ARIMA(Consumption) 2019 Q3 N(0.67, 0.33) 0.673
#> 2 ARIMA(Consumption) 2019 Q4 N(0.64, 0.35) 0.635
#> 3 ARIMA(Consumption) 2020 Q1 N(0.87, 0.37) 0.867
#> 4 ARIMA(Consumption) 2020 Q2  N(0.73, 0.4) 0.730
fcst %>% autoplot()
#> Error: Problem with `mutate()` input `80%`.
#> x A <hilo> object cannot be named.
#> ℹ Input `80%` is `hilo(Consumption, 80)`.

Created on 2020-08-05 by the reprex package (v0.3.0)

mitchelloharawild commented 3 years ago

Thanks, this would be a fabletools issue with a map()/lapply() of some sort. I'm surprised that the named vector worked at all in fabletools given the issue that this new error addresses.

mitchelloharawild commented 3 years ago

MRE:

library(fabletools)
fable(
  time = 1, dist = distributional::dist_normal(0,1),
  index = time, distribution = dist, response = "y"
) %>% 
  hilo()
#> Warning: The dimnames of the fable's distribution are missing and have been set
#> to match the response variables.
#> Error: Problem with `mutate()` input `80%`.
#> x A <hilo> object cannot be named.
#> ℹ Input `80%` is `hilo(dist, 80)`.

Created on 2020-08-06 by the reprex package (v0.3.0)

mitchelloharawild commented 3 years ago

Actually seems to be from the apply in distributional: MMMRE (more minimal MRE):

library(distributional)
dist <- dist_normal(0,1)
dimnames(dist) <- "y"
hilo(dist, 95)
#> Error: A <hilo> object cannot be named.

Created on 2020-08-06 by the reprex package (v0.3.0)