Skip to content

Commit 7294c00

Browse files
committed
correct symmetrization, enhance documentation of the "ahead" param in flatline_forecaster().
1 parent d606741 commit 7294c00

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

R/flatline_forecaster.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ flatline_forecaster <- function(
9494
#' Constructs a list of arguments for [flatline_forecaster()].
9595
#'
9696
#' @inheritParams arx_args_list
97+
#' @param ahead Integer. Unlike [arx_forecaster()], this doesn't have any effect
98+
#' on the predicted values. Predictions are always the most recent observation.
99+
#' However, this _does_ impact the residuals stored in the object. Residuals
100+
#' are calculated based on this number to mimic how badly you would have done.
101+
#' So for example, `ahead = 7` will create residuals by comparing values
102+
#' 7 days apart.
97103
#'
98104
#' @return A list containing updated parameter choices with class `flatline_alist`.
99105
#' @export

R/layer_cdc_flatline_quantiles.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ propogate_samples <- function(
149149
for (iter in 2:max_ahead) {
150150
samp <- shuffle(samp)
151151
raw <- raw + samp
152-
if (symmetrize) symmetric <- raw - (median(raw) + p)
152+
if (symmetrize) symmetric <- raw - (median(raw) - p)
153153
else symmetric <- raw
154154
if (nonneg) symmetric <- pmax(0, symmetric)
155155
res[[iter]] <- symmetric
156156
}
157157
}
158158
res <- res[aheads]
159159
list(tibble::tibble(
160-
aheads = aheads,
160+
ahead = aheads,
161161
.pred_distn = map_vec(
162162
res, ~ dist_quantiles(quantile(.x, quantiles), tau = quantiles)
163163
)

0 commit comments

Comments
 (0)