This repository contains the code used for the main analysis presented in the study "Social inequalities mediate temperature-child maltreatment associations in Africa". The code is written in R and is intended to illustrate the primary model used in the manuscript.
# README
## Overview
This repository contains the code used for the main analysis presented in the study "Social inequalities mediate temperature-child maltreatment associations in Africa". The code is written in R and is intended to illustrate the primary model used in the manuscript.
## R Code
The R script contains the main analysis model. It uses a mixed-effects logistic regression model together with a natural-spline temperature basis to assess the association between temperature percentile exposure and child maltreatment. The script also identifies the minimum-risk temperature percentile and estimates the odds ratio at the 95th temperature percentile.
## Files in the Repository
- `main_analysis_methods_only.R`: R code for the main analysis model using an analysis-ready dataset.
- `README.md`: repository description and usage notes.
## Usage
To use the script, prepare an analysis-ready dataset first and ensure the required R packages are installed in your environment.
Before running the script:
- place the input dataset in this folder or update the input path in the script
- edit the column-name settings at the top of the script if your dataset uses different variable names
Then run:
```bash
Rscript main_analysis_methods_only.R
```
## Citation
If you use this code in your research, please cite the corresponding study:
He, C., Fawzi, W.W. Social inequalities mediate temperature–child maltreatment associations in Africa. Nat. Clim. Chang. (2026).
doi.org