Skip to content

Commit d7edbab

Browse files
authored
Merge branch 'main' into lcb-day1-regression
2 parents 7fd61ee + d428894 commit d7edbab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13806
-8641
lines changed

_code/nhsn_v_hhs.R

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
library(epiprocess)
2+
3+
hhs_arch <- read_csv("https://healthdata.gov/resource/g62h-syeh.csv?$limit=90000&$select=date,state,previous_day_admission_influenza_confirmed") %>%
4+
mutate(
5+
geo_value = tolower(state),
6+
time_value = as.Date(date) - 1L,
7+
hhs = previous_day_admission_influenza_confirmed
8+
) |>
9+
select(geo_value, time_value, hhs) |>
10+
as_epi_df() |>
11+
group_by(geo_value) |>
12+
epi_slide_sum(
13+
hhs,
14+
na.rm = TRUE,
15+
.window_size = 7L,
16+
.ref_time_values = seq.Date(as.Date("2020-01-04"), as.Date("2024-04-24"), by = 7),
17+
) |>
18+
mutate(hhs = hhs_7dsum, hhs_7dsum = NULL)
19+
20+
convert_epiweek_to_season <- function(epiyear, epiweek) {
21+
# Convert epiweek to season
22+
update_inds <- epiweek <= 39
23+
epiyear <- ifelse(update_inds, epiyear - 1, epiyear)
24+
25+
season <- paste0(epiyear, "/", substr((epiyear + 1), 3, 4))
26+
return(season)
27+
}
28+
29+
epiweeks_in_year <- function(year) {
30+
last_week_of_year <- seq.Date(as.Date(paste0(year, "-12-24")),
31+
as.Date(paste0(year, "-12-31")),
32+
by = 1
33+
)
34+
return(max(as.numeric(MMWRweek::MMWRweek(last_week_of_year)$MMWRweek)))
35+
}
36+
37+
convert_epiweek_to_season_week <- function(epiyear, epiweek, season_start = 39) {
38+
season_week <- epiweek - 39
39+
update_inds <- season_week <= 0
40+
if (!any(update_inds)) {
41+
# none need to be updated
42+
return(season_week)
43+
}
44+
# last year's # of epiweeks determines which week in the season we're at at
45+
# the beginning of the year
46+
season_week[update_inds] <- season_week[update_inds] +
47+
sapply(epiyear[update_inds] - 1, epiweeks_in_year)
48+
49+
return(season_week)
50+
}
51+
52+
df <- readr::read_csv("https://data.cdc.gov/resource/ua7e-t2fy.csv?$limit=20000&$select=weekendingdate,jurisdiction,totalconfflunewadm")
53+
df <- df %>%
54+
mutate(
55+
epiweek = epiweek(weekendingdate),
56+
epiyear = epiyear(weekendingdate)
57+
) %>%
58+
left_join(
59+
(.) %>%
60+
distinct(epiweek, epiyear) %>%
61+
mutate(
62+
season = convert_epiweek_to_season(epiyear, epiweek),
63+
season_week = convert_epiweek_to_season_week(epiyear, epiweek)
64+
),
65+
by = c("epiweek", "epiyear")
66+
)
67+
68+
69+
to_compare <- df %>%
70+
mutate(time_value = as.Date(weekendingdate), geo_value = tolower(jurisdiction), nhsn = totalconfflunewadm) %>%
71+
select(-weekendingdate, -jurisdiction, -totalconfflunewadm) %>%
72+
full_join(hhs_arch, by = join_by(geo_value, time_value)) %>%
73+
select(time_value, geo_value, old_source = nhsn, new_source = hhs)
74+
75+
saveRDS(
76+
df |>
77+
mutate(time_value = as.Date(weekendingdate), geo_value = tolower(jurisdiction), nhsn = totalconfflunewadm) %>%
78+
select(-weekendingdate, -jurisdiction, -totalconfflunewadm),
79+
here::here("_data", "climatological_model_data.rds")
80+
)
81+
saveRDS(to_compare, here::here("_data", "hhs_v_nhsn.rds"))
82+

_data/climatological_model_data.rds

24.1 KB
Binary file not shown.

_data/hhs_v_nhsn.rds

36.9 KB
Binary file not shown.

_freeze/slides/day1-afternoon/execute-results/html.json

+2-2
Large diffs are not rendered by default.

_freeze/slides/day1-afternoon/figure-revealjs/final-vs-revisions-plot-1.svg

+798-267
Loading

_freeze/slides/day1-afternoon/figure-revealjs/nchs-plot-val-different-ver-1.svg

+1,401-386
Loading

_freeze/slides/day1-afternoon/figure-revealjs/nowcast-fun-plot-results-1.svg

+246-634
Loading

_freeze/slides/day1-afternoon/figure-revealjs/nowcast-smoothed-vis-1.svg

+269-686
Loading

_freeze/slides/day1-afternoon/figure-revealjs/plot-revision-patterns-1.svg

+387-402
Loading

_freeze/slides/day2-afternoon/execute-results/html.json

+2-2
Large diffs are not rendered by default.

_freeze/slides/day2-afternoon/figure-revealjs/arx-geo-pooling-plot-1.svg

+251-308
Loading

_freeze/slides/day2-afternoon/figure-revealjs/arx-geo-pooling-plot-h7-1.svg

+262-297
Loading

_freeze/slides/day2-afternoon/figure-revealjs/arx-multiple-h-plot-1.svg

+311-249
Loading

_freeze/slides/day2-afternoon/figure-revealjs/arx-no-geo-pooling-plot-1.svg

+252-273
Loading

_freeze/slides/day2-afternoon/figure-revealjs/arx-no-geo-pooling-plot-h7-1.svg

+258-282
Loading

_freeze/slides/day2-afternoon/figure-revealjs/arx-with-grf-1.svg

+3-3
Loading

_freeze/slides/day2-afternoon/figure-revealjs/autoplot-7dav-deaths-1.svg

+193-187
Loading

_freeze/slides/day2-afternoon/figure-revealjs/autoplot-deaths-1.svg

+192-186
Loading

_freeze/slides/day2-afternoon/figure-revealjs/hhs-ca-wy-plot-1.svg

+338
Loading

_freeze/slides/day2-afternoon/figure-revealjs/outliers-fig-1.svg

+16-12
Loading

_freeze/slides/day2-afternoon/figure-revealjs/unnamed-chunk-2-1.svg

+550
Loading

_freeze/slides/day2-afternoon/figure-revealjs/unnamed-chunk-5-1.svg

+860
Loading

_freeze/slides/day2-morning/execute-results/html.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)