Skip to content

Commit 10b6161

Browse files
committed
-1 ahead has gotten borked
1 parent 4d41254 commit 10b6161

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

R/forecasters/data_validation.R

+10
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ filter_extraneous <- function(epi_data, filter_source, filter_agg_level) {
9797
return(epi_data)
9898
}
9999

100+
#' the minus one ahead causes problems for `quantile_regression` if that data is
101+
#' actually present, so we should filter it out
102+
filter_minus_one_ahead <- function(epi_data, ahead) {
103+
if (ahead < 0) {
104+
dont_include <- attr(epi_data, "metadata")$as_of + ahead
105+
epi_data %<>% filter(time_value < dont_include)
106+
}
107+
epi_data
108+
}
109+
100110
#' Unwrap an argument if it's a list of length 1
101111
#'
102112
#' Many of our arguments to the forecasters come as lists not because we expect

R/forecasters/forecaster_scaled_pop_seasonal.R

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ scaled_pop_seasonal <- function(
7676
epi_data %<>% filter_extraneous(filter_source, filter_agg_level)
7777
# this is a temp fix until a real fix gets put into epipredict
7878
epi_data <- clear_lastminute_nas(epi_data, cols = c(outcome, extra_sources))
79+
# predicting the -1 ahead when it is present sometimes lead to freezeing
80+
epi_data %<>% filter_minus_one_ahead(ahead)
7981
# this next part is basically unavoidable boilerplate you'll want to copy
8082
args_input <- list(...)
8183
# edge case where there is no data or less data than the lags; eventually epipredict will handle this

0 commit comments

Comments
 (0)