|
13 | 13 | #' @importFrom rlang %||% |
14 | 14 | #' @export |
15 | 15 | ensemble_climate_linear <- function( |
16 | | - forecasts, |
17 | | - aheads, |
18 | | - other_weights = NULL, |
19 | | - probs = covidhub_probs(), |
20 | | - min_climate_ahead_weight = 0.05, |
21 | | - max_climate_ahead_weight = 0.90, |
22 | | - min_climate_quantile_weight = 0.1, |
23 | | - max_climate_quantile_weight = 1 |
24 | | -) { |
| 16 | + forecasts, |
| 17 | + aheads, |
| 18 | + other_weights = NULL, |
| 19 | + probs = covidhub_probs(), |
| 20 | + min_climate_ahead_weight = 0.05, |
| 21 | + max_climate_ahead_weight = 0.90, |
| 22 | + min_climate_quantile_weight = 0.1, |
| 23 | + max_climate_quantile_weight = 1) { |
| 24 | + browser() |
| 25 | + last_data <- min(forecasts$target_end_date) |
| 26 | + forecast_date <- min(forecasts$forecast_date) |
| 27 | + latency <- as.integer(forecast_date - last_data) / 7 |
| 28 | + aheads <- aheads + latency |
| 29 | + forecasts %<>% filter(grepl("climate|linear", forecaster)) %>% mutate(forecast_date = last_data) |
25 | 30 | weights <- |
26 | 31 | make_ahead_weights(aheads, min_climate_ahead_weight, max_climate_ahead_weight) %>% |
27 | 32 | left_join( |
@@ -83,7 +88,8 @@ ensemble_climate_linear <- function( |
83 | 88 | mutate(value = weight * value) %>% |
84 | 89 | group_by(geo_value, forecast_date, target_end_date, quantile) %>% |
85 | 90 | summarize(value = sum(value, na.rm = TRUE), .groups = "drop") %>% |
86 | | - sort_by_quantile() |
| 91 | + sort_by_quantile() %>% |
| 92 | + mutate(forecast_date = .env$forecast_date) |
87 | 93 | return(weighted_forecasts) |
88 | 94 | } |
89 | 95 |
|
|
0 commit comments