Bayesian spatio-temporal modelling of HIV and NCD mortality in Sub-Saharan Africa using INLA and BYM2 models
# SADC HIV-NCD Bayesian spatial analysis
This repository contains the R code used for the revised manuscript:
**Uncovering Spatial Co-dependence and Potential Syndemic Overlap: A Bayesian Stacked-Likelihood Model of HIV Prevalence and NCD Mortality in Southern Africa**
The analysis estimates a primary stacked-likelihood Bayesian areal model and a shared-component sensitivity model for HIV prevalence and major NCD mortality in 13 Southern African Development Community countries, 2000-2019.
## Repository structure
```text
.
├── sadc_hiv_ncd_inla_analysis.R
├── README.md
├── data/
│ ├── sadc2025.csv
│ ├── HIV_df.csv
│ ├── sadc.shp
│ ├── sadc.dbf
│ ├── sadc.shx
│ └── sadc.prj
└── outputs/ # created by the script
├── figures/
├── tables/
└── models/
```
## Required input files
The script expects the following files in a `data/` folder:
1. `sadc2025.csv`: NCD panel data. Required columns are:
- `country`
- `year`
- `observed_deaths`
- `expected_deaths`
- `ncdstype`
- `gdpercpta`
- `urbrte`
- `hcexp`
- `avrgprecp`
- `avrgtemp`
2. `HIV_df.csv`: HIV prevalence data. Required columns are:
- `country`
- `year`
- `hiv_prev`
3. `sadc.shp` and associated shapefile sidecar files. The shapefile must contain a `country` column.
## R version and packages
The script requires R >= 4.1 because it uses the base R pipe operator (`|>`).
Required R packages:
- `INLA`
- `sf`
- `spdep`
- `dplyr`
- `ggplot2`
- `readr`
- `stringr`
- `tmap`
- `scales`
- `tidyr`
- `purrr`
- `tibble`
- `data.table`
- `grid`
INLA is not installed from CRAN. It can be installed using:
```r
install.packages(
"INLA",
repos = c(getOption("repos"), INLA = "
inla.r-inla-download.org"),
dep = TRUE
)
```
## How to run
Place the input files in the `data/` folder, set the working directory to the repository root, and run:
```r
source("sadc_hiv_ncd_inla_analysis.R")
```
The script creates the `outputs/` folder automatically.
## Main analytical steps
The script …