This repository contains the working code for MS259, a SALURBAL-C study evaluating the short-term association between temperature and homicide mortality in 307 Latin American cities. The workflow ingests daily mortality counts that were multiply imputed (100 draws), fits distributed lag non-linear models (DLNMs), pools estimates with Rubin’s rules, estimate a joint Wald test, and produces descriptive tables, figures, and sensitivity analyses.
Moraes SL, Rodriguez DA, Schinasi LH, Kephart JL, Dronova I, Bakhtsiyarava M, Caiaffa WT, Rangel-Moreno K, Rodriguez-Villamizar LA, O'Neill M, de Lima Friche AA, Herrera López AB, Alazraqui M, Magalhães AS, Sarmiento OL, Sánchez BN, Gouveia N. Ambient temperature and homicide mortality in 307 Latin American cities: a case time series design. Environ Res. 2026 Feb 27:124083. https://doi.org/10.1016/j.envres.2026.124083.
| Script | Description |
|---|---|
functions_dlnm.R |
Utility helpers (fqaic, get_cen, and Rubin's rule) used across DLNM scripts |
load_imputed.R |
Loads the median-imputed dataset and constructs DLNM objects (cbt, knot specs, percentiles) |
00_data wrangling.R |
Reads raw city-level SAS files, aggregates deaths by subgroup, merges other datasets (temperature, clusters, census data and GDP), and writes per-city per-imputation parquet files |
01_data_wrangling.R |
Creates a single median-imputed dataset, aaggregates deaths by subgroup, merges other datasets (temperature, clusters, census data and GDP) |
02.median_imputation_dataset_descriptive.R |
Creates a single median-imputed dataset, aaggregates deaths by subgroup, merges other datasets (temperature, clusters, census data and GDP) |
02a.median_imputation_descriptive.R |
Descriptive summaries by city and country from the median dataset |
02b.figure_1.R |
Map - cities temperature profiles |
02c.table_1.R |
Table 1 (country-level summaries) - deaths, temperature, population, and homicide rate from median-imputed dataset |
02d.Supplementary_table_2.R |
city-level supplementary table of homicides and temperature from median-imputed dataset |
02e_median_imputation_main_subgroup_effects.R |
Runs DLNM models using median-imputed data across all cities; estimates subgroup effects for |
03.rubin_imputation_main_effect.R |
Runs DLNMs across 100 imputations, pools with Rubin’s rules, exports coefficients, and creates RR tables |
03a.figure_2.R |
Plot the main-effect curve from the 100 imputation dataset |
03b.supplementary_figure_1.R |
Plot pooled predictions |
03c.supplementary_figure_2.R |
Plot temperature percentiles (lag x-axis) |
04_sensitivity_knots_lag7.R |
Sensitivity analysis varying exposure knots (lag 7). Pools results and plots multi-panel comparison |
04a_sensitivity_knots_lag8.R |
Sensitivity analysis varying exposure knots (lag 8). Pools results and plots multi-panel comparison |
04b_sensitivity_main_effect_country2.R |
Sensitivity analysis of main effect by country and plot supplementary figure 3 |
04c_sensitivity_linear_sup_table_2.R |
Sensitivity with linear exposure function, and exports RR tables |
05_subgroup_sex.R |
Stratified by sex, Rubin-pooled DLNMs, and exports RR tables |
06_subgroup_age.R |
Stratified by age, Rubin-pooled DLNMs, and exports RR tables |
06a_subgroup_plot_fig_4.R |
Plot figure 4 (age and sex) |
07_temp_cluster.R |
Rubin-pooled DLNMs for each temperature city profile (cluster k = 6), and exports RR tables |
07a_cluster_plotting.R |
Plot Figure 3 - city temperature profile and overall curve |
08_EDF.R |
Computes excess death fractions (EDF) - overall and extreme heat |
09.table_2.R |
Builds combined results table summarising RR and EDF across models |
10_interaction.R |
Tests effect modification by education and GDP; pools interaction terms |
10a_plot_interaction.R |
Plot figure 5 |
10b_test_interaction.R |
Run a joint Wald test |
11_non_imputed.R |
sensitivity analysis for non-imputed raw counts (Rubin-pooled DLNMs) |
11a_non_imputed_median_imputed_sensitivity.R |
Plots the comparison of imputed vs. non-imputed results |