Skip to content

Commit cc1b515

Browse files
committed
formatting
1 parent 4723d89 commit cc1b515

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

vignettes/backtesting.Rmd

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,21 @@ aheads and some variations we will use later.
240240
```{r arx-kweek-preliminaries, warning = FALSE}
241241
forecast_wrapper <- function(
242242
epi_data, aheads, outcome, predictors,
243-
process_data = identity
244-
) {
245-
map(aheads,
246-
\(ahead) {
247-
arx_forecaster(
248-
process_data(epi_data), outcome, predictors,
249-
args_list = arx_args_list(
250-
ahead = ahead,
251-
lags = c(0:7, 14, 21),
252-
adjust_latency = "extend_ahead")
253-
)$predictions %>%
254-
pivot_quantiles_wider(.pred_distn)}) %>%
243+
process_data = identity) {
244+
map(
245+
aheads,
246+
\(ahead) {
247+
arx_forecaster(
248+
process_data(epi_data), outcome, predictors,
249+
args_list = arx_args_list(
250+
ahead = ahead,
251+
lags = c(0:7, 14, 21),
252+
adjust_latency = "extend_ahead"
253+
)
254+
)$predictions %>%
255+
pivot_quantiles_wider(.pred_distn)
256+
}
257+
) %>%
255258
bind_rows()
256259
}
257260
```
@@ -269,24 +272,25 @@ archives, and bind the results together.
269272
forecast_dates <- seq(
270273
from = as.Date("2020-09-01"),
271274
to = as.Date("2021-11-01"),
272-
by = "1 month")
275+
by = "1 month"
276+
)
273277
aheads <- c(1, 7, 14, 21, 28)
274278
275279
version_faithless <- archive_cases_dv_subset_faux %>%
276-
epix_slide(
277-
~forecast_wrapper(.x, aheads, "percent_cli", "percent_cli"),
278-
.before = 120,
279-
.versions = forecast_dates
280-
) %>%
281-
mutate(version_faithful = FALSE)
280+
epix_slide(
281+
~ forecast_wrapper(.x, aheads, "percent_cli", "percent_cli"),
282+
.before = 120,
283+
.versions = forecast_dates
284+
) %>%
285+
mutate(version_faithful = FALSE)
282286
283287
version_faithful <- doctor_visits %>%
284-
epix_slide(
285-
~forecast_wrapper(.x, aheads, "percent_cli", "percent_cli"),
286-
.before = 120,
287-
.versions = forecast_dates
288-
) %>%
289-
mutate(version_faithful = TRUE)
288+
epix_slide(
289+
~ forecast_wrapper(.x, aheads, "percent_cli", "percent_cli"),
290+
.before = 120,
291+
.versions = forecast_dates
292+
) %>%
293+
mutate(version_faithful = TRUE)
290294
291295
forecasts <-
292296
bind_rows(
@@ -349,7 +353,8 @@ p2 <-
349353
geom_point(aes(y = .pred, color = factor(time_value)), size = 0.75) +
350354
geom_vline(
351355
data = percent_cli_data %>% filter(geo_value == geo_choose) %>% select(-version_faithful),
352-
aes(color = factor(version), xintercept = version), lty = 2) +
356+
aes(color = factor(version), xintercept = version), lty = 2
357+
) +
353358
geom_line(
354359
data = percent_cli_data %>% filter(geo_value == geo_choose),
355360
aes(x = time_value, y = percent_cli, color = factor(version)),

0 commit comments

Comments
 (0)