33# ' @param frosting a `frosting` postprocessor
44# ' @param ... Unused, include for consistency with other layers.
55# ' @param quantile_levels numeric vector of probabilities with values in (0,1)
6- # ' referring to the desired quantile.
6+ # ' referring to the desired quantile. Note that 0.5 will always be included
7+ # ' even if left out by the user.
78# ' @param symmetrize logical. If `TRUE` then interval will be symmetric.
89# ' @param by_key A character vector of keys to group the residuals by before
910# ' calculating quantiles. The default, `c()` performs no grouping.
2829# ' f <- frosting() %>%
2930# ' layer_predict() %>%
3031# ' layer_residual_quantiles(
31- # ' quantile_levels = c(0.0275 , 0.975),
32+ # ' quantile_levels = c(0.025 , 0.975),
3233# ' symmetrize = FALSE
3334# ' ) %>%
3435# ' layer_naomit(.pred)
4849# ' p2 <- forecast(wf2)
4950layer_residual_quantiles <- function (
5051 frosting , ... ,
51- quantile_levels = c(0.05 , 0.5 , 0.95 ),
52+ quantile_levels = c(0.025 , 0.1 , 0.25 , 0. 5 , 0.75 , 0.9 , 0.975 ),
5253 symmetrize = TRUE ,
5354 by_key = character (0L ),
5455 name = " .pred_distn" ,
@@ -59,6 +60,7 @@ layer_residual_quantiles <- function(
5960 arg_is_chr(by_key , allow_empty = TRUE )
6061 arg_is_probabilities(quantile_levels )
6162 arg_is_lgl(symmetrize )
63+ quantile_levels <- sort(unique(c(0.5 , quantile_levels )))
6264 add_layer(
6365 frosting ,
6466 layer_residual_quantiles_new(
0 commit comments