Code and data for: Population age structure and tuberculosis burden reduction in Africa, 2015–2024: a cross-country ecological analysisOverviewThis repository contains the complete replication package for the manuscript "Population age structure and tuberculosis burden reduction in Africa, 2015–2024: a cross-country ecological analysis". The package includes the analytic dataset, Python analysis scripts, and supporting documentation required to reproduce all tables, figures, and results presented in the paper.BackgroundThe WHO African Region recorded a 28% reduction in tuberculosis incidence and a 46% reduction in tuberculosis deaths between 2015 and 2024, but progress varied widely across countries. This study assessed whether population age structure is associated with country-level changes in tuberculosis incidence and mortality-milestone attainment in Africa, and whether any association persists after accounting for baseline tuberculosis burden and structural characteristics.Repository Contentspanel_v3.csv: Complete country-level analytic dataset (n=54 countries) containing tuberculosis incidence (2015–2024), demographic characteristics (median age, old-age dependency ratio, population density), and socioeconomic indicators (GDP per capita, HIV prevalence, urban population share).comprehensive_analysis.py: Main analysis script implementing ordinary least squares regression with heteroskedasticity-consistent (HC3) standard errors. Runs Models 1–4, generates correlation matrices, variance inflation factor diagnostics, and leave-one-country-out sensitivity analysis.mortality_and_desc.py: Implements Firth penalized logistic regression for binary milestone outcomes (incidence milestone, mortality milestone, both jointly) and generates descriptive statistics for Table 2.mortality_sensitivity.py: Runs sensitivity analyses restricted to WHO African Region member states and full covariate adjustment for the mortality milestone outcome.requirements.txt: Lists all Python package dependencies with version specifications.README.md: Detailed instructions for setting up the environment and running the code.Methods SummaryThe study is a cross-country ecological analysis of 54 African and North African countries. The primary outcome is the log incidence rate ratio (log of 2024 incidence divided by 2015 incidence). Ordinary least squares regression with HC3 robust standard errors was used in four staged specifications: (1) median age alone; (2) plus population density; (3) plus baseline incidence; (4) plus GDP per capita, HIV prevalence, and urban population share. Secondary outcomes (milestone attainment) were analysed using Firth penalized logistic regression to address small-sample bias. Sensitivity analyses included regional restriction to WHO African Region member states, leave-one-country-out re-estimation, alternative age measures (old-age dependency ratio), alternative outcome specifications, and assessment of non-linearity.Data SourcesTuberculosis incidence: World Bank World Development Indicators (release 15 July 2026; SH.TBS.INCD), compiled from WHO Global Tuberculosis Programme estimates.Demographic covariates: United Nations World Population Prospects 2024 revision.Milestone classifications: WHO Global Tuberculosis Report 2025, Table 3.Socioeconomic covariates: World Bank World Development Indicators.RequirementsThe code was developed and tested using Python 3.11.4 with the following packages:numpy==1.24.3scipy==1.10.1pandas==2.0.3matplotlib==3.7.2UsageClone or download this repository.Install dependencies: pip install -r requirements.txtRun scripts sequentially:python comprehensive_analysis.pypython mortality_and_desc.pypython mortality_sensitivity.pyOutputcomprehensive_analysis.py: Prints correlation matrices, VIF, main model coefficients (Tables 3, S3, S4, S6, S7, S8), and exports loo_results.csv.mortality_and_desc.py: Prints Firth logistic regression results (Table 4) and descriptive outcome counts (Table 2).mortality_sensitivity.py: Prints regional and adjusted Firth models.LicenseThis code is provided under the MIT License. The dataset is derived from publicly available sources (WHO, World Bank, UN WPP) and is shared for reproducibility purposes under CC BY 4.0.CitationIf you use this code or data, please cite the associated manuscript and this Figshare repository.