*** Data and code for the paper 'Estimating COVID-19 excess deaths during and after the pandemic: A Bayesian model, with an application to New Zealand'*** ## Contents of each folder - `Makefile` File to control analysis - `Dockerfile` File to install packages and run analysis - `docker` Installation scripts run by docker - `data` All input data for analysis - `src` All code for analysis - `out` Intermediate and final results ## Code authors John Bryant wrote all the code used in this analysis. John Bryant and Junni Zhang are the authors of the main package used, 'bage'. ## Running the code If you are familiar with Docker, then the best way to completely replicate the analysis is to use the Dockerfile included in this folder. If you are familiar with Makefile, using the `make` application allows you to automatically run some or all of the analysis. Otherwise, you can run the analysis script by script from within R. The results shown in the paper were produced using R 4.4.3. You will need the following R packages to run the analysis. For perfect replicability you will need R 4.4.3, and the package versions indicated. To just try out the code, the version number should not matter, unless a function is not backwardly compatible. - zoo 1.8-15 - readr 2.2.0 - dplyr 1.2.1 - tidyr 1.3.2 - ggplot2 4.0.3 - patchwork 1.3.2 - lubridate 1.9.5 - rvec 1.0.1 - poputils 0.6.1 - readxl 1.5.0 - xtable 1.8-8 - command 0.1.3 - bage 0.10.9 ## What the code in `src` does 1. Prepare the data - deaths.R - popn.R - exposure.R - data.R - example_ages.R - covid_deaths.R 2. Make plots of the raw data - data_deaths_expose.R - data_monthly.R 3. Fit the model - mod.R 4. Extract parameter estimates - aug.R (extract rates) - comp.R (extract higher level parameters) 5. Calculate derived quantities - excess.R (calculate excess mortality) - excess_ag.R (calculate aggregated excess mortality) 6. Check the model - repdata_lifeexp.R - repdata_month.R - heldback.R - vals_heldback.R 7. Create plots for the main part of the paper - fig_data_deaths_expose.R - fig_data_monthly.R - fig_time.R - fig_agesextime.R - fig_season.R - fig_rates.R - fig_heldback.R - fig_excess.R - fig_excess_ag.R - fig_excess_covid.R 8. Create plots for the appendix - fig_rates_all.R - fig_excess_agesex.R - fig_repdata_lifeexp.R - fig_repdata_month.R 9. Create tables - tab_excess.R - tab_hyper.R 10. Create indicators for heldback data test, cited in text - num_heldback.R 11. Make plot for social media - fig_excess_covid.R