R Code for predicting HIV status using random forest and XG Boost on data from four countries in Sub-Saharan Africa
# Machine-learning-to-guide-HIV-Interventions
R Code for predicting HIV status using random forest and XG Boost on data from four countries in Sub-Saharan Africa
# Machine Learning to Guide HIV Interventions
This repository contains the analysis code used in the study:
**“Leveraging Modern Machine Learning Techniques to Guide Targeted HIV Interventions and Prevention Strategies in Sub-Saharan Africa .”**
The scripts implement statistical and machine learning methods to identify predictors of HIV positivity and explore cross-country patterns using population-based HIV survey data. The analysis supports evidence-based targeting of HIV prevention and treatment interventions.
---
# Repository Structure
The repository includes the following R scripts:
### 1. SMOTE Random Forest Model
**File:**
smote_random_forest_model.R
Purpose:
* Applies **SMOTE (Synthetic Minority Oversampling Technique)** to address class imbalance in HIV status.
* Trains a **Random Forest model** to predict HIV positivity.
* Extracts variable importance to identify key predictors.
---
### 2. XGBoost Model
**File:**
xgboost_model.R
Purpose:
* Implements an **Extreme Gradient Boosting (XGBoost)** model.
* Provides an alternative machine learning approach for predicting HIV status.
* Allows comparison of model performance with Random Forest.
---
### 3. Logistic Regression Analysis
**File:**
logistic_regression_analysis.R
Purpose:
* Fits a **logistic regression model** to estimate associations between predictors and HIV status.
* Generates plots to aid interpretation and comparison with machine learning models.
---
### 4. Chi-Square Analysis
**File:**
chi_square_analysis.R
Purpose:
* Performs **chi-square tests** to examine bivariate associations between categorical predictors and HIV status.
---
### 5. Rank Correlation and Heatmap
**File:**
kendall_spearman_heatmap.R
Purpose:
* Calculates **Spearman and Kendall rank correlations**.
* Produces **heatmaps** to compare predic …