Skip to content

Commit

Permalink
correct symmetrization, enhance documentation of the "ahead" param in…
Browse files Browse the repository at this point in the history
… `flatline_forecaster()`.
  • Loading branch information
dajmcdon committed Sep 24, 2023
1 parent d606741 commit 7294c00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions R/flatline_forecaster.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ flatline_forecaster <- function(
#' Constructs a list of arguments for [flatline_forecaster()].
#'
#' @inheritParams arx_args_list
#' @param ahead Integer. Unlike [arx_forecaster()], this doesn't have any effect
#' on the predicted values. Predictions are always the most recent observation.
#' However, this _does_ impact the residuals stored in the object. Residuals
#' are calculated based on this number to mimic how badly you would have done.
#' So for example, `ahead = 7` will create residuals by comparing values
#' 7 days apart.
#'
#' @return A list containing updated parameter choices with class `flatline_alist`.
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/layer_cdc_flatline_quantiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ propogate_samples <- function(
for (iter in 2:max_ahead) {
samp <- shuffle(samp)
raw <- raw + samp
if (symmetrize) symmetric <- raw - (median(raw) + p)
if (symmetrize) symmetric <- raw - (median(raw) - p)
else symmetric <- raw
if (nonneg) symmetric <- pmax(0, symmetric)
res[[iter]] <- symmetric
}
}
res <- res[aheads]
list(tibble::tibble(
aheads = aheads,
ahead = aheads,
.pred_distn = map_vec(
res, ~ dist_quantiles(quantile(.x, quantiles), tau = quantiles)
)
Expand Down

0 comments on commit 7294c00

Please sign in to comment.