@@ -7,8 +7,8 @@ vignette: >
77 %\VignetteEncoding{UTF-8}
88---
99
10- ``` {r setup , include = FALSE}
11- source(here::here("vignettes", " _common.R") )
10+ ``` {r, include = FALSE}
11+ source(" _common.R")
1212```
1313
1414``` {r pkgs, include=FALSE, echo=TRUE}
@@ -132,16 +132,20 @@ Let's use the `epix_as_of()` method to generate a snapshot of the archive at the
132132last date, and then run the forecaster.
133133
134134``` {r}
135+ # Let's forecast 14 days prior to the last date in the archive, to compare.
136+ forecast_date <- archive_cases_dv_subset$versions_end - 14
135137# The .versions argument selects only the last version in the archive and
136138# produces a forecast only on that date.
137139forecasts <- archive_cases_dv_subset %>%
138140 epix_slide(
139141 ~ arx_forecaster(
140142 .x,
141143 outcome = "percent_cli",
142- predictors = c("case_rate_7d_av", "percent_cli")
143- )$predictions,
144- .versions = archive_cases_dv_subset$versions_end
144+ predictors = c("case_rate_7d_av", "percent_cli"),
145+ args_list = arx_args_list()
146+ )$predictions %>%
147+ pivot_quantiles_wider(.pred_distn),
148+ .versions = forecast_date
145149 )
146150# Join the forecasts with with the latest data at the time of the forecast to
147151# compare. Since `percent_cli` data has a few days of lag, we use `tidyr::fill` to
@@ -152,9 +156,9 @@ forecasts %>%
152156 epix_as_of(archive_cases_dv_subset$versions_end) %>%
153157 group_by(geo_value) %>%
154158 tidyr::fill(percent_cli),
155- by = c("geo_value", "forecast_date " = "time_value")
159+ by = c("geo_value", "target_date " = "time_value")
156160 ) %>%
157- select(geo_value, forecast_date, .pred, .pred_distn , percent_cli)
161+ select(geo_value, forecast_date, .pred, `0.05`, `0.95` , percent_cli)
158162```
159163
160164The resulting epi_df now contains two new columns: ` .pred ` and ` .pred_distn ` ,
0 commit comments