Skip to content

Commit

Permalink
Merge pull request #8 from mymil/update_data
Browse files Browse the repository at this point in the history
Update results with newer provisional 2020-2021 mortality data
  • Loading branch information
Joe-Wasserman authored Nov 5, 2021
2 parents 3e3f19e + 0016765 commit 9e7fbef
Show file tree
Hide file tree
Showing 33 changed files with 145,271 additions and 57,215 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.1.3.9131
rev: v0.1.3.9133
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand All @@ -13,7 +13,7 @@ repos:
rev: v4.0.1
hooks:
- id: check-added-large-files
args: ['--maxkb=9216']
args: ['--maxkb=40960']
- id: end-of-file-fixer
exclude: '\.Rd'
- repo: local
Expand All @@ -22,5 +22,5 @@ repos:
name: Don't commit common R artifacts
entry: Cannot commit .Rhistory, .RData, .Rds or .rds.
language: fail
files: '\.Rhistory|\.RData|\.Rds|\.rds$'
files: '\.Rhistory|\.RData$'
# `exclude: <regex>` to allow committing specific files.
28 changes: 17 additions & 11 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ library(texPreview)
knitr::opts_chunk$set(
echo = FALSE,
collapse = TRUE,
warning = FALSE,
message = FALSE,
dev.args = list(png = list(type = "cairo")), dpi = 96,
fig.path = "README_files/"
)
Expand Down Expand Up @@ -44,14 +46,19 @@ united_states_county_quarterly_excess_deaths_estimates <- data.table::fread(
keepLeadingZeros = TRUE
)
total_excess_deaths <- united_states_county_quarterly_excess_deaths_estimates %>%
total_excess_deaths_2020 <- united_states_county_quarterly_excess_deaths_estimates %>%
filter(year == 2020L) %>%
pull(excess_deaths) %>%
sum(na.rm = TRUE)
total_excess_deaths_2021 <- united_states_county_quarterly_excess_deaths_estimates %>%
filter(year == 2021L) %>%
pull(excess_deaths) %>%
sum(na.rm = TRUE)
```

This repository contains code and data to estimate **expected deaths** and **excess deaths** in the United States in 2020 by **county** and **quarter**.
This model estimates that there were about `r round(total_excess_deaths)` excess deaths in the United States in 2020.
This repository contains code and data to estimate **expected deaths** and **excess deaths** in the United States in 2020 and 2021 by **county** and **quarter**.
This model estimates that there were about `r round(total_excess_deaths_2020)` excess deaths in the United States in 2020 and `r round(total_excess_deaths_2021)` in the first two quarters of 2021, for a total of `r round(sum(total_excess_deaths_2020, total_excess_deaths_2021))`.

Estimated excess deaths are available at [`/blob/main/results/united_states_county_quarterly_excess_deaths_estimates.csv`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/results/united_states_county_quarterly_excess_deaths_estimates.csv).

Expand All @@ -66,26 +73,25 @@ Estimated excess deaths are available at [`/blob/main/results/united_states_coun

Note: County-months wither fewer than 10 deaths are censored in the source data.

* NCHS Provisional COVID-19 Deaths by Quarter, County and Age for 2020
* NCHS Provisional COVID-19 Deaths by Quarter and County

https://data.cdc.gov/NCHS/AH-Provisional-COVID-19-Deaths-by-Quarter-County-a/ypxr-mz8e
https://data.cdc.gov/NCHS/AH-Provisional-COVID-19-Death-Counts-by-Quarter-an/dnhi-s2bf

These public domain all-cause and COVID-19 mortality data were obtained for 2020 and compared to estimated expected deaths to calculate excess deaths.
The age groups in these data are not mutually exclusive.
To minimize the prevalence of suppression in these data, values from the two widest age groups, under 65 and 65 and older, were summed.
These public domain all-cause and COVID-19 mortality data were obtained for 2020-2021 and compared to estimated expected deaths to calculate excess deaths.

Note: Values for county-quarter-age group with fewer than 9 deaths are suppressed.
Note: Values for county-quarters with fewer than 9 deaths are suppressed in these data.

* US Census Population Estimates

Population estimates for 2015-2020 were retrieved from the [US Census Bureau Population Estimates](https://www.census.gov/programs-surveys/popest/technical-documentation/research/evaluation-estimates/2020-evaluation-estimates/2010s-counties-total.html), because these data are not yet included in the Census Bureau Data API.
2020 population estimates were used for 2021.

Note: This product uses Census Bureau data but is not endorsed or certified by the Census Bureau.

# Excess Deaths Model

The excess deaths model used began as an adaptation of *The Economist*'s [excess mortality model](https://github.com/TheEconomist/covid-19-excess-deaths-tracker), but has since diverged.
For details on model selection and performance, see [`/blob/main/docs/modeling_and_model_selection.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/docs/modeling_and_model_selection.md).
For details on model selection and performance, see [`/blob/main/results/README.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/results/README.md).

Given the large number of counties in the United States (over 3000), a linear mixed model with county, county set, and census division as random grouping factors was used to make estimation tractable.
These random grouping factors enable each county, county set, and state to have their own intercepts in the final model.
Expand Down Expand Up @@ -135,7 +141,7 @@ Note that these estimates are only y-hat directly from the initial model, **not*

# Model Performance

For more details on model selection and performance, see [`/blob/main/docs/modeling_and_model_selection.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/docs/modeling_and_model_selection.md).
For more details on model selection and performance, see [`/blob/main/results/README.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/results/README.md).

Because the COVID-19 pandemic only began in the United States partway through March, 2020, we can evaluate model performance by examining concordance of predicted and observed deaths in Q1 2020.

Expand Down
93 changes: 45 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ COVID-19 United States Excess Deaths by county and quarter
<!-- README.md is generated from README.Rmd. Please edit that file -->

This repository contains code and data to estimate **expected deaths**
and **excess deaths** in the United States in 2020 by **county** and
**quarter**. This model estimates that there were about 461870 excess
deaths in the United States in 2020.
and **excess deaths** in the United States in 2020 and 2021 by
**county** and **quarter**. This model estimates that there were about
411714 excess deaths in the United States in 2020 and 138509 in the
first two quarters of 2021, for a total of 550223.

Estimated excess deaths are available at
[`/blob/main/results/united_states_county_quarterly_excess_deaths_estimates.csv`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/results/united_states_county_quarterly_excess_deaths_estimates.csv).
Expand All @@ -26,27 +27,24 @@ Estimated excess deaths are available at
Note: County-months wither fewer than 10 deaths are censored in the
source data.

- NCHS Provisional COVID-19 Deaths by Quarter, County and Age for 2020
- NCHS Provisional COVID-19 Deaths by Quarter and County

<https://data.cdc.gov/NCHS/AH-Provisional-COVID-19-Deaths-by-Quarter-County-a/ypxr-mz8e>
<https://data.cdc.gov/NCHS/AH-Provisional-COVID-19-Death-Counts-by-Quarter-an/dnhi-s2bf>

These public domain all-cause and COVID-19 mortality data were
obtained for 2020 and compared to estimated expected deaths to
calculate excess deaths. The age groups in these data are not
mutually exclusive. To minimize the prevalence of suppression in
these data, values from the two widest age groups, under 65 and 65
and older, were summed.
obtained for 2020-2021 and compared to estimated expected deaths to
calculate excess deaths.

Note: Values for county-quarter-age group with fewer than 9 deaths
are suppressed.
Note: Values for county-quarters with fewer than 9 deaths are
suppressed in these data.

- US Census Population Estimates

Population estimates for 2015-2020 were retrieved from the [US
Census Bureau Population
Estimates](https://www.census.gov/programs-surveys/popest/technical-documentation/research/evaluation-estimates/2020-evaluation-estimates/2010s-counties-total.html),
because these data are not yet included in the Census Bureau Data
API.
API. 2020 population estimates were used for 2021.

Note: This product uses Census Bureau data but is not endorsed or
certified by the Census Bureau.
Expand All @@ -58,7 +56,7 @@ The excess deaths model used began as an adaptation of *The Economist*’s
model](https://github.com/TheEconomist/covid-19-excess-deaths-tracker),
but has since diverged. For details on model selection and performance,
see
[`/blob/main/docs/modeling_and_model_selection.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/docs/modeling_and_model_selection.md).
[`/blob/main/results/README.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/results/README.md).

Given the large number of counties in the United States (over 3000), a
linear mixed model with county, county set, and census division as
Expand Down Expand Up @@ -98,7 +96,7 @@ here](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-de
# Model Performance

For more details on model selection and performance, see
[`/blob/main/docs/modeling_and_model_selection.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/docs/modeling_and_model_selection.md).
[`/blob/main/results/README.md`](https://github.com/mymil/covid-19-united-states-county-quarterly-excess-deaths/blob/main/results/README.md).

Because the COVID-19 pandemic only began in the United States partway
through March, 2020, we can evaluate model performance by examining
Expand Down Expand Up @@ -147,44 +145,43 @@ sessionInfo()
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] lmerTest_3.1-3 lme4_1.1-26 Matrix_1.3-2
## [1] lmerTest_3.1-3 lme4_1.1-27.1 Matrix_1.3-2
## [4] texPreview_1.5 tinytex_0.34 knitr_1.31
## [7] equatiomatic_0.3.0.9000 lubridate_1.7.10 data.table_1.14.0
## [10] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.5
## [13] purrr_0.3.4 readr_2.0.2 tidyr_1.1.3
## [16] tibble_3.1.0 ggplot2_3.3.5 tidyverse_1.3.1
##
## loaded via a namespace (and not attached):
## [1] rdocsyntax_0.4.1.9000 minqa_1.2.4 colorspace_2.0-0
## [4] ellipsis_0.3.1 rprojroot_2.0.2 base64enc_0.1-3
## [7] fs_1.5.0 rstudioapi_0.13 farver_2.1.0
## [10] ggrepel_0.9.1 fansi_0.4.2 xml2_1.3.2
## [13] splines_4.0.4 cachem_1.0.4 jsonlite_1.7.2
## [16] nloptr_1.2.2.2 broom_0.7.6 dbplyr_2.1.1
## [19] png_0.1-7 broom.mixed_0.2.6 shiny_1.6.0
## [22] clipr_0.7.1 compiler_4.0.4 httr_1.4.2
## [25] backports_1.2.1 assertthat_0.2.1 fastmap_1.1.0
## [28] cli_3.0.1 svgPanZoom_0.3.4 later_1.2.0
## [31] htmltools_0.5.1.1 tools_4.0.4 coda_0.19-4
## [34] gtable_0.3.0 glue_1.4.2 reshape2_1.4.4
## [37] V8_3.4.0 Rcpp_1.0.7 cellranger_1.1.0
## [40] vctrs_0.3.7 pdftools_2.3.1 nlme_3.1-152
## [43] xfun_0.26 rvest_1.0.0 mime_0.10
## [46] lifecycle_1.0.0 statmod_1.4.35 MASS_7.3-53
## [49] scales_1.1.1 hms_1.0.0 promises_1.2.0.1
## [52] rematch2_2.1.2 TMB_1.7.20 yaml_2.2.1
## [55] curl_4.3 memoise_2.0.0 stringi_1.5.3
## [58] highr_0.8 desc_1.3.0 boot_1.3-26
## [61] rlang_0.4.10 pkgconfig_2.0.3 evaluate_0.14
## [64] lattice_0.20-41 labeling_0.4.2 tidyselect_1.1.0
## [67] here_1.0.1 plyr_1.8.6 magrittr_2.0.1
## [70] R6_2.5.0 magick_2.7.3 generics_0.1.0
## [73] DBI_1.1.1 pillar_1.6.0 haven_2.3.1
## [76] whisker_0.4 withr_2.4.2 mgcv_1.8-33
## [79] modelr_0.1.8 crayon_1.4.1 utf8_1.2.1
## [82] tzdb_0.1.2 rmarkdown_2.7 grid_4.0.4
## [85] readxl_1.3.1 qpdf_1.1 reprex_2.0.0
## [88] digest_0.6.27 xtable_1.8-4 httpuv_1.6.0
## [91] numDeriv_2016.8-1.1 details_0.2.1 munsell_0.5.0
## [94] askpass_1.1
## [1] nlme_3.1-152 fs_1.5.0 httr_1.4.2
## [4] rprojroot_2.0.2 numDeriv_2016.8-1.1 TMB_1.7.20
## [7] tools_4.0.4 backports_1.2.1 utf8_1.2.1
## [10] R6_2.5.0 svgPanZoom_0.3.4 mgcv_1.8-33
## [13] DBI_1.1.1 colorspace_2.0-0 withr_2.4.2
## [16] tidyselect_1.1.0 curl_4.3 compiler_4.0.4
## [19] cli_3.0.1 rvest_1.0.0 xml2_1.3.2
## [22] desc_1.3.0 labeling_0.4.2 scales_1.1.1
## [25] askpass_1.1 digest_0.6.27 minqa_1.2.4
## [28] rmarkdown_2.7 base64enc_0.1-3 pkgconfig_2.0.3
## [31] htmltools_0.5.1.1 highr_0.8 dbplyr_2.1.1
## [34] fastmap_1.1.0 rlang_0.4.10 readxl_1.3.1
## [37] rstudioapi_0.13 shiny_1.6.0 farver_2.1.0
## [40] generics_0.1.0 jsonlite_1.7.2 broom.mixed_0.2.6
## [43] magrittr_2.0.1 Rcpp_1.0.7 munsell_0.5.0
## [46] fansi_0.4.2 clipr_0.7.1 lifecycle_1.0.0
## [49] stringi_1.5.3 whisker_0.4 yaml_2.2.1
## [52] MASS_7.3-53 plyr_1.8.6 grid_4.0.4
## [55] ggrepel_0.9.1 promises_1.2.0.1 crayon_1.4.1
## [58] details_0.2.1 lattice_0.20-41 haven_2.3.1
## [61] splines_4.0.4 hms_1.0.0 magick_2.7.3
## [64] pillar_1.6.0 boot_1.3-26 reshape2_1.4.4
## [67] reprex_2.0.0 glue_1.4.2 evaluate_0.14
## [70] pdftools_2.3.1 qpdf_1.1 V8_3.4.0
## [73] modelr_0.1.8 nloptr_1.2.2.2 vctrs_0.3.7
## [76] png_0.1-7 tzdb_0.1.2 httpuv_1.6.0
## [79] cellranger_1.1.0 gtable_0.3.0 rematch2_2.1.2
## [82] assertthat_0.2.1 cachem_1.0.4 xfun_0.26
## [85] mime_0.10 xtable_1.8-4 broom_0.7.9
## [88] coda_0.19-4 later_1.2.0 memoise_2.0.0
## [91] ellipsis_0.3.1 rdocsyntax_0.4.1.9000 here_1.0.1
```
Binary file added README_files/equation-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/plot_comparison-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9e7fbef

Please sign in to comment.