Descriptive analysis of trends in deaths
A descriptive analysis of trends in mortality using data from the Office for National Statistics (ONS). The R code can be used to recreate the analysis described in COVID-19 chart series and the Stata code can be used to recreate the analysis in our COVID-19 chart series analysis showing excess mortality.
This project uses publically available data that can be downloaded from the ONS website. The data were released with an Open Government Licence.
The R code provided downloads the data you need and cleans it. We have used the groupings provided by the ONS, summarised below.
The do file was written with Stata version 15. To run the whole code successfully, it is necessary to download and save all of the spreadsheets from 2010 to 2020. This can be done manually or using the R code provided. Running the code cleans and appends all of the data from the tabs called “Weekly figures 20**”. The final result should include a new dataset for all years with the following variables: all deaths; 5-years average of all deaths; respiratory disease deaths; COVID-19 deaths; deaths by age groups and gender; deaths by government office regions.
The final part of the code directly saves the data used to create the chart.
The R scripts were written under R version 3.6.3 (2020-02-29) — “Holding the windsock” and RStudio Version 1.2.5033.
The following R packages (available on CRAN) are needed:
Functions from internal package, theme_THF() and scale_XXX_THF() can be removed or be replaced with eg theme_minimal().
The Stata code was written using Stata version 15.
The ‘src’ folder contains
This project is licensed under the MIT License.