View source: R/flusight_hub_formatter.R
flusight_hub_formatter | R Documentation |
This function converts predictions from any of the included forecasters into
a format (nearly) ready for submission to the 2023-24
FluSight-forecast-hub.
See there for documentation of the required columns. Currently, only
"quantile" forcasts are supported, but the intention is to support both
"quantile" and "pmf". For this reason, adding the output_type
column should
be done via the ...
argument. See the examples below. The specific required
format for this forecast task is here.
flusight_hub_formatter(object, ..., .fcast_period = c("daily", "weekly"))
object |
a data.frame of predictions or an object of class
|
... |
< |
.fcast_period |
Control whether the |
A tibble::tibble. If ...
is empty, the result will contain the
columns reference_date
, horizon
, target_end_date
, location
,
output_type_id
, and value
. The ...
can perform mutations on any of
these.
library(dplyr)
library(epiprocess)
weekly_deaths <- covid_case_death_rates %>%
filter(
time_value >= as.Date("2021-09-01"),
geo_value %in% c("ca", "ny", "dc", "ga", "vt")
) %>%
select(geo_value, time_value, death_rate) %>%
left_join(state_census %>% select(pop, abbr), by = c("geo_value" = "abbr")) %>%
mutate(deaths = pmax(death_rate / 1e5 * pop * 7, 0)) %>%
select(-pop, -death_rate) %>%
group_by(geo_value) %>%
epi_slide(~ sum(.$deaths), .window_size = 7, .new_col_name = "deaths_7dsum") %>%
ungroup() %>%
filter(weekdays(time_value) == "Saturday")
cdc <- cdc_baseline_forecaster(weekly_deaths, "deaths_7dsum")
flusight_hub_formatter(cdc)
flusight_hub_formatter(cdc, target = "wk inc covid deaths")
flusight_hub_formatter(cdc, target = paste(horizon, "wk inc covid deaths"))
flusight_hub_formatter(cdc, target = "wk inc covid deaths", output_type = "quantile")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.