|
32 | 32 | #' These samples are spaced evenly on the (0, 1) scale, F_X(x) resulting
|
33 | 33 | #' in linear interpolation on the X scale. This is achieved with
|
34 | 34 | #' [stats::quantile()] Type 7 (the default for that function).
|
| 35 | +#' @param symmetrize Logical. If `TRUE`, does two things: (i) forces the |
| 36 | +#' "empirical" CDF of residuals to be symmetric by pretending that for every |
| 37 | +#' actually-observed residual X we also observed another residual -X, and (ii) |
| 38 | +#' at each ahead, forces the median simulated value to be equal to the point |
| 39 | +#' prediction by adding or subtracting the same amount to every simulated |
| 40 | +#' value. Adjustments in (ii) take place before propagating forward and |
| 41 | +#' simulating the next ahead. This forces any 1-ahead predictive intervals to |
| 42 | +#' be symmetric about the point prediction, and encourages larger aheads to be |
| 43 | +#' more symmetric. |
35 | 44 | #' @param nonneg Logical. Force all predictive intervals be non-negative.
|
36 |
| -#' Because non-negativity is forced _before_ propagating forward, this |
37 |
| -#' has slightly different behaviour than would occur if using |
38 |
| -#' [layer_threshold()]. |
| 45 | +#' Because non-negativity is forced _before_ propagating forward, this has |
| 46 | +#' slightly different behaviour than would occur if using [layer_threshold()]. |
| 47 | +#' Thresholding at each ahead takes place after any shifting from |
| 48 | +#' `symmetrize`. |
39 | 49 | #'
|
40 | 50 | #' @return an updated `frosting` postprocessor. Calling [predict()] will result
|
41 | 51 | #' in an additional `<list-col>` named `.pred_distn_all` containing 2-column
|
@@ -232,6 +242,9 @@ slather.layer_cdc_flatline_quantiles <-
|
232 | 242 | propogate_samples <- function(
|
233 | 243 | r, p, quantile_levels, aheads, nsim, symmetrize, nonneg) {
|
234 | 244 | max_ahead <- max(aheads)
|
| 245 | + if (symmetrize) { |
| 246 | + r <- c(r, -r) |
| 247 | + } |
235 | 248 | samp <- quantile(r, probs = c(0, seq_len(nsim - 1)) / (nsim - 1), na.rm = TRUE)
|
236 | 249 | res <- list()
|
237 | 250 |
|
|
0 commit comments