Replication data and code for a cluster-RCT evaluating digital adherence technologies for TB treatment in Kenya
# Keheala Study 2 — Data Analysis in Python
Data and analysis code for a cluster-randomized controlled trial (RCT) evaluating digital adherence technologies for tuberculosis (TB) treatment in Kenya, conducted in partnership with USAID.
The study randomized patients across four arms — Control, SMS Reminders, a digital platform (SBCC), and Keheala — and measured treatment outcomes including unsuccessful outcomes, loss to follow-up (LTFU), and death.
## Quick Start
**Requirements:** Python 3 with `pandas`, `numpy`, and `statsmodels`.
```bash
pip install pandas numpy statsmodels
```
**Run the analysis** (scripts can be run in any order):
```bash
python3 Python_Analysis/analysis_manuscript.py # Tables 1–4
python3 Python_Analysis/analysis_si.py # Supplementary Tables SI5–SI13
python3 Python_Analysis/analysis_dqa.py # Data Quality Assessment (SI14)
python3 Python_Analysis/generate_consort.py # CONSORT flow diagram numbers
```
Output: LaTeX `.tex` files are written to `Python_Analysis/output/`.
## Repository Structure
```
Keheala_RCTII/
├── README.md
├── deidentified_data/level2/ # De-identified datasets for analysis
│ ├── study2_cleaned.csv # Study data (N=17,160 rows; mITT N=14,962)
│ ├── TIBU_firstnm_deidentified.csv # Kenya national TB registry
│ ├── Urine_Test_Results.csv # Urine verification data
│ └── DQA_combined.csv # Data quality assessment records
├── Python_Analysis/
│ ├── analysis_manuscript.py # Tables 1–4 (main manuscript)
│ ├── analysis_si.py # Supplementary Tables SI5–SI13
│ ├── analysis_dqa.py # Data Quality Assessment (SI14)
│ ├── generate_consort.py # CONSORT flow diagram
│ ├── prepare_study_data.py # Data cleaning [reference only]
│ ├── prepare_TIBU_data.py # TIBU aggregation [reference only]
│ ├── deidentify_data.py …