Closed vpnagraj closed 2 years ago
candidate fix:
replace_ili_nowcast <- function (ilidat, start_date = today(), weeks_to_replace = 1) {
days_back <- (1:(weeks_to_replace + 1)) * 7
dates_back <- start_date - days_back
ilinow <- get_nowcast_ili(dates = dates_back)
ilinow <- ilinow %>% dplyr::filter(location %in% ilidat$location)
message(paste0("Replacing weighted_ili with nowcast weighted_ili on dates: ",
paste(dates_back, collapse = ", ")))
res <- ilidat %>% dplyr::full_join(ilinow, by = c("location",
"abbreviation", "epiyear", "epiweek")) %>% dplyr::mutate(week_start = MMWRweek::MMWRweek2Date(epiyear,
epiweek)) %>% dplyr::arrange(location, week_start) %>%
tidyr::fill(region_type, region, .direction = "down") %>%
dplyr::mutate(weighted_ili = ifelse(!is.na(weighted_ili_now),
weighted_ili_now, weighted_ili)) %>% dplyr::select(-weighted_ili_now)
return(res)
}
Fixed in 6493fd9 same PR as #121
── R CMD check results ───────────────────────────────────────────── fiphde 0.2.0 ────
Duration: 39.6s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
R CMD check succeeded
thanks @stephenturner
looks like i accidentally removed this when fixing something else: https://github.com/signaturescience/fiphde/commit/68dd3c6e75dc011c02f4af5bd61bd2f321dcc1b4
ill take care of it.
the
replace_ili_nowcast()
function calcuates the "dates back" for the ILI nowcast augmentation by using the current date. when retrospectively forecasting, however, the forecast date will not be the current date. we should make this function a little more flexible by adding an argument for "start_date"