-
Notifications
You must be signed in to change notification settings - Fork 8
Debug apparent case_rate_7d_av
discrepancies
#251
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
Comments
Regenerating [the data object would resolve] this discrepancy, although using the |
|
Working on regenerating this object, I looked to the API. It turns out we haven't fixed our smoothing discrepancies there either. Here's some code that demonstrates that: df1_cases <- epidatr::pub_covidcast(
"jhu-csse",
"confirmed_incidence_num",
"state",
"day",
"*",
epidatr::epirange("2020-03-01", "2021-12-31")
)
df2_cases <- epidatr::pub_covidcast(
"jhu-csse",
"confirmed_7dav_incidence_num",
"state",
"day",
"*",
epidatr::epirange("2020-03-01", "2021-12-31")
)
df <- inner_join(df1_cases, df2_cases %>% select(geo_value, time_value, value), by = c("geo_value", "time_value"))
df %>%
as_epi_df() %>%
group_by(geo_value) %>%
epi_slide(cases_7d_av2 = sum(value.x) / 7, before = 7L) %>%
ungroup() %>%
mutate(discrepancy = cases_7d_av2 - value.y) %>%
{
quantile <- quantile(.$discrepancy, 0.9)
filter(., .$discrepancy > quantile)
} %>%
select(geo_value, time_value, cases_7d_av2, discrepancy) %>%
filter(geo_value == "ny")
### Output
An `epi_df` object, 323 x 4 with metadata:
* geo_type = state
* time_type = day
* as_of = 2023-03-10
# A tibble: 323 × 4
geo_value time_value cases_7d_av2 discrepancy
* <chr> <date> <dbl> <dbl>
1 ny 2020-03-29 7034 683
2 ny 2020-03-30 7353. 813.
3 ny 2020-03-31 7853. 685.
4 ny 2020-04-01 9242. 737.
5 ny 2020-04-02 9991. 937.
6 ny 2020-04-03 10580. 1043.
7 ny 2020-04-04 11001. 1100.
8 ny 2020-04-05 11471. 1035.
9 ny 2020-04-06 11845. 1002.
10 ny 2020-04-07 11902. 1313.
# ℹ 313 more rows
# ℹ Use `print(n = ...)` to see more rows I'm planning to regenerate this just by requesting |
@dshemetov When I last checked, simply re-downloading from API fixed it. In your test script, things might be messed up due to |
I already made a PR fix that calculates manually, but oof is a 7day window really specified with a |
Yes, |
Created on 2022-12-01 by the reprex package (v2.0.1)
Also, fix apparent documentation bug:
We want to say that the non-7dav signals are directly from JHU CSSE, while Delphi calculated the moving averages.
The text was updated successfully, but these errors were encountered: