This function is most useful for converting a forecast date and an ahead specification from epiweek to days. It allows days as well.

get_target_ahead(forecast_date, incidence_period, ahead)

Arguments

forecast_date

Date object or string of the form "YYYY-MM-DD", indicating date on which forecasts will be made about some period (e.g., epiweek). For example, if forecast_date = "2020-05-11", incidence_period = "day", and ahead = 3, then, we'd be making forecasts for "2020-05-14".

incidence_period

String indicating the incidence period, either "epiweek" or "day".

ahead

Vector of (one or more) integers. How many epiweeks/days ahead are you forecasting? If incidence_period = "epiweek" and forecast_date is Sunday or Monday, then ahead = 1 means the epiweek that includes the forecast date; if forecast_date falls on a Tuesday through Saturday, then it is the following epiweek. If incidence_period = "day", then ahead = 1 means the day after forecast date.

See also

Examples

fd <- "2021-03-22" # a monday get_target_ahead(fd, "epiweek", 1) # forecast the following Saturday
#> [1] 5
get_target_ahead("2021-03-23", "epiweek", 1) # forecast the Saturday after next
#> [1] 11
get_target_ahead(fd, "day", 1) # forecast tomorrow
#> [1] 1