Skip to content

Commit 561c95c

Browse files
authored
epipredict updates (#186)
1 parent 54ee888 commit 561c95c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

R/forecasters/forecaster_baseline_linear.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ forecaster_baseline_linear <- function(epi_data, ahead, log = FALSE, sort = FALS
108108
quantile_forecast <-
109109
point_forecast %>%
110110
rowwise() %>%
111-
mutate(quantile = get_quantile(value, ahead) %>% nested_quantiles()) %>%
112-
unnest(quantile) %>%
111+
mutate(dist = get_quantile(value, ahead)) %>%
112+
pivot_quantiles_longer(dist) %>%
113+
rename(quantile_levels = dist_quantile_level, values = dist_value) %>%
114+
select(-value) %>%
113115
left_join(population_data, by = "geo_value") %>%
114116
rename(quantile = quantile_levels) %>%
115117
{

R/forecasters/formatters.R

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
#' @export
1515
format_storage <- function(pred, true_forecast_date, target_end_date) {
1616
pred %>%
17-
mutate(.dstn = nested_quantiles(.pred_distn)) %>%
18-
unnest(.dstn) %>%
19-
select(-any_of(c(".pred_distn", ".pred", "time_value"))) %>%
20-
rename(quantile = quantile_levels, value = values) %>%
17+
epipredict::pivot_quantiles_longer(.pred_distn) %>%
18+
mutate(value = .pred_distn_value, quantile = .pred_distn_quantile_level) %>%
19+
select(-starts_with(".pred"), -any_of(c("time_value"))) %>%
2120
relocate(where(is.character), where(is.factor), forecast_date, target_end_date = target_date, quantile, value)
2221
}
2322

0 commit comments

Comments
 (0)