Closed
Description
TL;DR: target_date
results in NA forecasts? If you comment out target_date
and uncomment ahead
lines below, the forecasts are reasonable.
r$> library(epidatr) # Access Delphi API
library(epipredict)
library(dplyr)
format_storage <- function(pred, true_forecast_date, target_end_date) {
pred %>%
mutate(
forecast_date = true_forecast_date,
.dstn = nested_quantiles(.pred_distn)
) %>%
unnest(.dstn) %>%
select(-any_of(c(".pred_distn", ".pred", "time_value"))) %>%
rename(quantile = quantile_levels, value = values, target_end_date =
target_date) %>%
relocate(geo_value, forecast_date, target_end_date, quantile, value)
}
epidata <- pub_covidcast(
source = "jhu-csse",
signals = "deaths_incidence_num",
time_type = "day",
geo_type = "state",
geo_values = c("ca", "tx", "fl"),
time_values = epirange(20210101, 20211231)
) %>%
select(geo_value, time_value, deaths = value) %>%
as_epi_df()
fit <- flatline_forecaster(
epidata,
outcome = "deaths",
args_list = flatline_args_list(
# ahead = 1L,
n_training = 7L,
forecast_date = as.Date("2021-12-31"),
target_date = as.Date("2022-01-01"),
quantile_levels = c(0.2, 0.5, 0.8),
)
)
format_storage(fit$predictions, as.Date("2021-12-31"), as.Date("2022-01-0
1"))
# A tibble: 9 × 5
geo_value forecast_date target_end_date quantile value
<chr> <date> <date> <dbl> <dbl>
1 ca 2021-12-31 2022-01-08 0.2 NA
2 ca 2021-12-31 2022-01-08 0.5 NA
3 ca 2021-12-31 2022-01-08 0.8 NA
4 fl 2021-12-31 2022-01-08 0.2 NA
5 fl 2021-12-31 2022-01-08 0.5 NA
6 fl 2021-12-31 2022-01-08 0.8 NA
7 tx 2021-12-31 2022-01-08 0.2 NA
8 tx 2021-12-31 2022-01-08 0.5 NA
9 tx 2021-12-31 2022-01-08 0.8 NA
Metadata
Metadata
Assignees
Labels
No labels