Code to reproduce the results in "Regional and national estimates of children affected by all-cause and COVID-19-associated orphanhood and caregiver death in Brazil, by age and family circumstance."
The primary analysis is performed in two steps:
- We generate samples of excess mortality and fertility, and then of orphanhood
- These samples are processed into the results
Generating the samples of fertility and orphanhood can be computationally expensive, particularly when estimating across many groups (such as by region and child-age, for example). We encourage you to leverage pre-generated samples available in the /samples/ folder for any downstream-analysis.
This repo contains the following scripts and folders:
generate_samples.R: Calls sampling functions from the/R/folder. Corresponding scripts*_hpc.Rand*_hpc_array.Rare included for running on HPC services. If re-running these scripts from scratch, they should be run in the order presented, as later scripts may depend on the output of earlier scripts./data/: Raw data (where available) and scripts to process them into consistent formats./outputs/: Figures from the paper and supplementary material/paper/: R scripts to generate tables and figures for the paper/R/: Functions to generate samples of excess mortality, fertility, and orphanhood/samples/: Pre-generated samples of excess mortality, fertility, and orphanhood
A flowchart of the core workflow to produce the samples of orphanhood. A higher quality .pdf version is available here.
The code in this repository requires the following R packages:
tidyverse: Standard data manipulation and visualisation packageszoo: Working with time series dataforeach: Parallel processingdoParallel: Parallel processingsurvey: Survey data analysisprogress: Progress bars for long-running operationscowplot: Combining ggplot2 plotsviridis: Color palettes for ggplot2clipr: Clipboard operations for copying data to clipboardDescTools: Descriptive statistics and data manipulationDemoTools: Demographic tools for RPNSIBGE: Functions for working with the Brazilian National Health Survey (PNS) datageobr: Functions for working with Brazilian geographic data
Most of these packages are standard R packages. In-text citations are provided in the manuscript and supplementary material where appropriate.