Skip to content

Commit b27d44f

Browse files
committed
fix: make sure nhsn data is latest
1 parent f830d1a commit b27d44f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

R/forecasters/forecaster_scaled_pop_seasonal.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ scaled_pop_seasonal <- function(epi_data,
142142
}
143143
}
144144

145+
# Make sure NHSN data is the latest available. This is important to make sure
146+
# that we use the right data when forecasting and selecting the training
147+
# window. We do this by removing any extra source data that could be older.
148+
max_time_nhsn <- epi_data %>%
149+
filter(source == "nhsn") %>%
150+
group_by(geo_value) %>%
151+
summarize(max_time_nhsn = max(time_value))
152+
epi_data %<>%
153+
filter(source == "nhsn") %>%
154+
bind_rows(
155+
epi_data %>%
156+
filter(source != "nhsn") %>%
157+
left_join(max_time_nhsn, by = "geo_value") %>%
158+
filter(time_value <= max_time_nhsn)
159+
)
160+
145161
if (drop_non_seasons) {
146162
season_data <- epi_data %>% drop_non_seasons()
147163
} else {

0 commit comments

Comments
 (0)