This function calculates quantiles when the prediction was distributional.
If the model producing the forecast is not distributional, it is recommended
to use layer_residual_quantiles() instead.
Value
an updated frosting postprocessor. An additional column of predictive
quantiles will be added to the predictions.
Details
Currently, the only distributional modes/engines are
rand_forest(mode = "regression") %>% set_engine("grf_quantiles")
If these engines were used, then this layer will grab out estimated (or extrapolated) quantiles at the requested quantile values.
Examples
jhu <- covid_case_death_rates %>%
  filter(time_value > "2021-11-01", geo_value %in% c("ak", "ca", "ny"))
r <- epi_recipe(jhu) %>%
  step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
  step_epi_ahead(death_rate, ahead = 7) %>%
  step_epi_naomit()
wf <- epi_workflow(r, quantile_reg(quantile_levels = c(.25, .5, .75))) %>%
  fit(jhu)
f <- frosting() %>%
  layer_predict() %>%
  layer_quantile_distn() %>%
  layer_naomit(.pred)
wf1 <- wf %>% add_frosting(f)
p <- forecast(wf1)
p
#> An `epi_df` object, 3 x 4 with metadata:
#> * geo_type  = state
#> * time_type = day
#> * as_of     = 2023-03-10
#> 
#> # A tibble: 3 × 4
#>   geo_value time_value     .pred .pred_distn
#>   <chr>     <date>     <qtls(3)>   <qtls(7)>
#> 1 ak        2021-12-31   [0.058]     [0.058]
#> 2 ca        2021-12-31   [0.179]     [0.179]
#> 3 ny        2021-12-31   [0.274]     [0.274]