Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

221 updated categorical rate change thresholds and algorithm for 2024 25 flusight season #224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions R/forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ forecast_categorical <- function(.forecast, .observed, method = "density", forma
} else if (method == "density") {

if(format != "hubverse") {
stop("Currently the desnity method only works with 'hubverse' forecast format.")
stop("Currently the density method only works with 'hubverse' forecast format.")
}

last_week <-
Expand Down Expand Up @@ -673,32 +673,32 @@ density_probs <- function(df, n_horizons = 5, ...){
"-1" = list(t1 = max(c(10, as.numeric(unique(df$count_rate1)))),
t2 = max(c(10, as.numeric(unique(df$count_rate2))))
),
"0" = list(t1 = max(c(10, as.numeric(unique(df$count_rate1)))),
"0" = list(t1 = max(c(10, as.numeric(unique(df$count_rate0p3)))),
t2 = max(c(10, as.numeric(unique(df$count_rate1p7))))
),
"1" = list(t1 = max(c(10, as.numeric(unique(df$count_rate0p5)))),
t2 = max(c(10, as.numeric(unique(df$count_rate3))))
),
"1" = list(t1 = max(c(10, as.numeric(unique(df$count_rate2)))),
"2" = list(t1 = max(c(10, as.numeric(unique(df$count_rate0p7)))),
t2 = max(c(10, as.numeric(unique(df$count_rate4))))
),
"2" = list(t1 = max(c(10, as.numeric(unique(df$count_rate2p5)))),
t2 = max(c(10, as.numeric(unique(df$count_rate5))))
),
"3" = list(t1 = max(c(10, as.numeric(unique(df$count_rate2p5)))),
"3" = list(t1 = max(c(10, as.numeric(unique(df$count_rate1)))),
t2 = max(c(10, as.numeric(unique(df$count_rate5))))
)
)
} else if (n_horizons == 4) {
thresh <-
switch (as.character(tmp_horizon),
"0" = list(t1 = max(c(10, as.numeric(unique(df$count_rate1)))),
t2 = max(c(10, as.numeric(unique(df$count_rate2))))
"0" = list(t1 = max(c(10, as.numeric(unique(df$count_rate0p3)))),
t2 = max(c(10, as.numeric(unique(df$count_rate1p7))))
),
"1" = list(t1 = max(c(10, as.numeric(unique(df$count_rate1)))),
"1" = list(t1 = max(c(10, as.numeric(unique(df$count_rate0p5)))),
t2 = max(c(10, as.numeric(unique(df$count_rate3))))
),
"2" = list(t1 = max(c(10, as.numeric(unique(df$count_rate2)))),
"2" = list(t1 = max(c(10, as.numeric(unique(df$count_rate0p7)))),
t2 = max(c(10, as.numeric(unique(df$count_rate4))))
),
"3" = list(t1 = max(c(10, as.numeric(unique(df$count_rate2p5)))),
"3" = list(t1 = max(c(10, as.numeric(unique(df$count_rate1)))),
t2 = max(c(10, as.numeric(unique(df$count_rate5))))
)
)
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
7 changes: 4 additions & 3 deletions data-raw/generate_sysdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ locations <-
## provenance of data file
# download.file("https://raw.githubusercontent.com/cdcepi/Flusight-forecast-data/master/data-locations/locations.csv",
# destfile=here::here("data-raw/legacy-rate-change.csv"))
## NOTE: this data was updated for the 2024-25 season and re-downloaded so we can use the correct thresholds
# download.file("https://raw.githubusercontent.com/cdcepi/Flusight-forecast-hub/main/auxiliary-data/locations.csv",
# destfile=here::here("data-raw/hubverse-rate-change.csv"))

# destfile=here::here("data-raw/hubverse-rate-change-2425.csv"))
## read the location crosswalk table from file downloaded from github
## select columns of interest
legacy_rate_change <-
read_csv(here::here("data-raw/legacy-rate-change.csv"), col_types="cccddd") %>%
select(location, count_rate1per100k, count_rate2per100k)

hubverse_rate_change <-
read_csv(here::here("data-raw/hubverse-rate-change.csv"), col_types="cccddddddd")
# read_csv(here::here("data-raw/hubverse-rate-change-2324.csv"), col_types="cccddddddd")
read_csv(here::here("data-raw/hubverse-rate-change-2425.csv"), col_types="cccddddddddd")

# Quantiles ---------------------------------------------------------------

Expand Down
54 changes: 54 additions & 0 deletions data-raw/hubverse-rate-change-2425.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
abbreviation,location,location_name,population,count_rate0p3,count_rate0p5,count_rate0p7,count_rate1,count_rate1p7,count_rate3,count_rate4,count_rate5
US,US,US,334914895,1005,1675,2344,3349,5694,10047,13397,16746
AL,01,Alabama,5108468,15,26,36,51,87,153,204,255
AK,02,Alaska,733406,2,4,5,7,12,22,29,37
AZ,04,Arizona,7431344,22,37,52,74,126,223,297,372
AR,05,Arkansas,3067732,9,15,21,31,52,92,123,153
CA,06,California,38965193,117,195,273,390,662,1169,1559,1948
CO,08,Colorado,5877610,18,29,41,59,100,176,235,294
CT,09,Connecticut,3617176,11,18,25,36,61,109,145,181
DE,10,Delaware,1031890,3,5,7,10,18,31,41,52
DC,11,District of Columbia,678972,2,3,5,7,12,20,27,34
FL,12,Florida,22610726,68,113,158,226,384,678,904,1131
GA,13,Georgia,11029227,33,55,77,110,187,331,441,551
HI,15,Hawaii,1435138,4,7,10,14,24,43,57,72
ID,16,Idaho,1964726,6,10,14,20,33,59,79,98
IL,17,Illinois,12549689,38,63,88,125,213,376,502,627
IN,18,Indiana,6862199,21,34,48,69,117,206,274,343
IA,19,Iowa,3207004,10,16,22,32,55,96,128,160
KS,20,Kansas,2940546,9,15,21,29,50,88,118,147
KY,21,Kentucky,4526154,14,23,32,45,77,136,181,226
LA,22,Louisiana,4573749,14,23,32,46,78,137,183,229
ME,23,Maine,1395722,4,7,10,14,24,42,56,70
MD,24,Maryland,6180253,19,31,43,62,105,185,247,309
MA,25,Massachusetts,7001399,21,35,49,70,119,210,280,350
MI,26,Michigan,10037261,30,50,70,100,171,301,401,502
MN,27,Minnesota,5737915,17,29,40,57,98,172,230,287
MS,28,Mississippi,2939690,9,15,21,29,50,88,118,147
MO,29,Missouri,6196156,19,31,43,62,105,186,248,310
MT,30,Montana,1132812,3,6,8,11,19,34,45,57
NE,31,Nebraska,1978379,6,10,14,20,34,59,79,99
NV,32,Nevada,3194176,10,16,22,32,54,96,128,160
NH,33,New Hampshire,1402054,4,7,10,14,24,42,56,70
NJ,34,New Jersey,9290841,28,46,65,93,158,279,372,465
NM,35,New Mexico,2114371,6,11,15,21,36,63,85,106
NY,36,New York,19571216,59,98,137,196,333,587,783,979
NC,37,North Carolina,10835491,33,54,76,108,184,325,433,542
ND,38,North Dakota,783926,2,4,5,8,13,24,31,39
OH,39,Ohio,11785935,35,59,83,118,200,354,471,589
OK,40,Oklahoma,4053824,12,20,28,41,69,122,162,203
OR,41,Oregon,4233358,13,21,30,42,72,127,169,212
PA,42,Pennsylvania,12961683,39,65,91,130,220,389,518,648
RI,44,Rhode Island,1095962,3,5,8,11,19,33,44,55
SC,45,South Carolina,5373555,16,27,38,54,91,161,215,269
SD,46,South Dakota,919318,3,5,6,9,16,28,37,46
TN,47,Tennessee,7126489,21,36,50,71,121,214,285,356
TX,48,Texas,30503301,92,153,214,305,519,915,1220,1525
UT,49,Utah,3417734,10,17,24,34,58,103,137,171
VT,50,Vermont,647464,2,3,5,6,11,19,26,32
VA,51,Virginia,8715698,26,44,61,87,148,261,349,436
WA,53,Washington,7812880,23,39,55,78,133,234,313,391
WV,54,West Virginia,1770071,5,9,12,18,30,53,71,89
WI,55,Wisconsin,5910955,18,30,41,59,100,177,236,296
WY,56,Wyoming,584057,2,3,4,6,10,18,23,29
PR,72,Puerto Rico,3205691,10,16,22,32,54,96,128,160