Skip to content

Commit 94de99d

Browse files
committed
better defaults in layer_residual_quantiles, force 0.5 and document
1 parent 7d31ee3 commit 94de99d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

R/layer_residual_quantiles.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
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.
@@ -28,7 +29,7 @@
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)
@@ -48,7 +49,7 @@
4849
#' p2 <- forecast(wf2)
4950
layer_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

Comments
 (0)