Datasets:
Formats:
csv
Languages:
English
Size:
10K - 100K
Tags:
health-financing
out-of-pocket
catastrophic-expenditure
financial-protection
Synthetic
healthcare
License:
Upload folder using huggingface_hub
Browse files- README.md +139 -0
- data/oop_high_oop_unprotected.csv +0 -0
- data/oop_low_oop_insured.csv +0 -0
- data/oop_moderate_oop_mixed.csv +0 -0
- generate_dataset.py +331 -0
- requirements.txt +3 -0
- validate_dataset.py +178 -0
- validation_report.png +3 -0
README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
- tabular-regression
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
tags:
|
| 9 |
+
- health-financing
|
| 10 |
+
- out-of-pocket
|
| 11 |
+
- catastrophic-expenditure
|
| 12 |
+
- financial-protection
|
| 13 |
+
- synthetic
|
| 14 |
+
- healthcare
|
| 15 |
+
- sub-saharan-africa
|
| 16 |
+
pretty_name: Out-of-Pocket Health Expenditure
|
| 17 |
+
size_categories:
|
| 18 |
+
- 10K<n<100K
|
| 19 |
+
configs:
|
| 20 |
+
- config_name: low_oop_insured
|
| 21 |
+
data_files: data/oop_low_oop_insured.csv
|
| 22 |
+
- config_name: moderate_oop_mixed
|
| 23 |
+
data_files: data/oop_moderate_oop_mixed.csv
|
| 24 |
+
default: true
|
| 25 |
+
- config_name: high_oop_unprotected
|
| 26 |
+
data_files: data/oop_high_oop_unprotected.csv
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
# Out-of-Pocket Health Expenditure
|
| 30 |
+
|
| 31 |
+
## Abstract
|
| 32 |
+
|
| 33 |
+
This synthetic dataset models household-level out-of-pocket (OOP) health spending across three sub-Saharan African scenarios: low OOP with strong insurance (Rwanda-like), moderate OOP with partial insurance (Ghana/Kenya-like), and high OOP with minimal financial protection (Nigeria/Chad-like). Each scenario contains 10,000 household records capturing OOP spending by category, catastrophic health expenditure, coping strategies, care-seeking behaviour, and impoverishment. Parameters are grounded in WHO AFRO financial protection reports, the Global Health Expenditure Database, and peer-reviewed literature.
|
| 34 |
+
|
| 35 |
+
## Parameterization Evidence Table
|
| 36 |
+
|
| 37 |
+
| Parameter | Value | Source | Year |
|
| 38 |
+
|-----------|-------|--------|------|
|
| 39 |
+
| SSA OOP as % CHE (median) | ~36% | WHO GHED | 2022 |
|
| 40 |
+
| Rwanda OOP as % CHE | ~12% | WHO GHED / Exemplars | 2022 |
|
| 41 |
+
| Nigeria OOP as % CHE | ~77% | WHO GHED | 2022 |
|
| 42 |
+
| OOP >25% of health spending | 31 SSA countries | WHO AFRO UHC Report | 2023 |
|
| 43 |
+
| OOP >50% of health spending | 11 SSA countries | WHO AFRO UHC Report | 2023 |
|
| 44 |
+
| Catastrophic spending (>10%) | 95M people in Africa | WHO AFRO | 2019 |
|
| 45 |
+
| Impoverishment by OOP | 150M+ in Africa | WHO AFRO | 2019 |
|
| 46 |
+
| Average OOP per person (Africa) | ~$35/year | WHO AFRO | 2019 |
|
| 47 |
+
| Medicines as % of OOP | 40-60% | Akazili et al. systematic review | 2022 |
|
| 48 |
+
| CHE incidence range (SSA) | 1-48% (10% threshold) | PMC9047424 | 2022 |
|
| 49 |
+
| SSA govt health budget share | <7% median (Abuja target 15%) | ODI / GHED | 2023 |
|
| 50 |
+
|
| 51 |
+
## Scenario Design
|
| 52 |
+
|
| 53 |
+
| Scenario | Exemplar | Insurance | OOP % CHE | Catastrophic | Mean OOP |
|
| 54 |
+
|----------|----------|-----------|-----------|-------------|----------|
|
| 55 |
+
| low_oop_insured | Rwanda/SA | 84% | 12% | 6.1% | $20 |
|
| 56 |
+
| moderate_oop_mixed | Ghana/Kenya | 29% | 36% | 22.5% | $116 |
|
| 57 |
+
| high_oop_unprotected | Nigeria/Chad | 5% | 72% | 36.3% | $271 |
|
| 58 |
+
|
| 59 |
+
## Dataset Schema
|
| 60 |
+
|
| 61 |
+
| Column | Type | Description |
|
| 62 |
+
|--------|------|-------------|
|
| 63 |
+
| id | int | Record identifier |
|
| 64 |
+
| household_size | int | Household members |
|
| 65 |
+
| ses_quintile | int | Wealth quintile (1=poorest) |
|
| 66 |
+
| residence | cat | Urban/rural |
|
| 67 |
+
| head_age | int | Household head age |
|
| 68 |
+
| head_sex | cat | Household head sex |
|
| 69 |
+
| has_insurance | binary | Health insurance coverage |
|
| 70 |
+
| chronic_conditions | int | Number of chronic conditions |
|
| 71 |
+
| household_income_usd | int | Annual income (USD) |
|
| 72 |
+
| health_events_12m | int | Health events in past year |
|
| 73 |
+
| sought_care | binary | Sought formal healthcare |
|
| 74 |
+
| primary_service | cat | Main service type used |
|
| 75 |
+
| facility_type | cat | Type of health facility |
|
| 76 |
+
| oop_total_usd | float | Total annual OOP (USD) |
|
| 77 |
+
| oop_medicines_usd | float | OOP on medicines |
|
| 78 |
+
| oop_outpatient_usd | float | OOP on outpatient care |
|
| 79 |
+
| oop_inpatient_usd | float | OOP on inpatient care |
|
| 80 |
+
| oop_transport_usd | float | OOP on transport |
|
| 81 |
+
| oop_diagnostic_usd | float | OOP on diagnostics |
|
| 82 |
+
| catastrophic_expenditure | binary | OOP >10% of income |
|
| 83 |
+
| impoverished_by_oop | binary | Pushed below poverty line |
|
| 84 |
+
| oop_pct_income | float | OOP as % of income |
|
| 85 |
+
| coping_strategy | cat | Primary coping mechanism |
|
| 86 |
+
| forgone_care | binary | Needed but did not seek care |
|
| 87 |
+
| year | int | Survey year (2020-2024) |
|
| 88 |
+
|
| 89 |
+
## Validation
|
| 90 |
+
|
| 91 |
+

|
| 92 |
+
|
| 93 |
+
## Usage
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
from datasets import load_dataset
|
| 97 |
+
ds = load_dataset("electricsheepafrica/oop-health-expenditure",
|
| 98 |
+
name="moderate_oop_mixed")
|
| 99 |
+
df = ds['train'].to_pandas()
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
```bash
|
| 103 |
+
pip install -r requirements.txt
|
| 104 |
+
python generate_dataset.py --all-scenarios --n 10000 --seed 42
|
| 105 |
+
python validate_dataset.py
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## Limitations
|
| 109 |
+
|
| 110 |
+
- **Synthetic data**: All records are computationally generated and must not be used for clinical or policy decisions.
|
| 111 |
+
- **Self-medication OOP**: Estimated for non-care-seekers using pharmacy/self-medication patterns; actual spending may vary.
|
| 112 |
+
- **Income proxy**: Based on SES quintile assignment, not measured household survey data.
|
| 113 |
+
- **Temporal**: Does not model year-on-year policy changes or COVID-19 spending shocks.
|
| 114 |
+
|
| 115 |
+
## References
|
| 116 |
+
|
| 117 |
+
1. WHO AFRO (2023). *Towards UHC: Tracking Financial Protection in the WHO African Region*. https://www.afro.who.int/publications/towards-universal-health-coverage
|
| 118 |
+
2. WHO AFRO (2023). UHC Day Report. https://www.afro.who.int/news/uhc-day-high-health-care-costs
|
| 119 |
+
3. WHO GHED (2022). https://apps.who.int/nha/database/
|
| 120 |
+
4. Akazili J et al. (2022). Catastrophic health expenditure in SSA: systematic review. *BMJ Open* 12(4). PMC9047424
|
| 121 |
+
5. ODI (2023). Health spending in SSA. https://odi.org/en/insights/what-do-we-know-about-health-spending
|
| 122 |
+
6. Exemplars in Global Health (2023). Rwanda CBHI. https://www.exemplars.health/topics/primary-health-care/rwanda
|
| 123 |
+
7. World Bank (2022). WDI. https://data.worldbank.org
|
| 124 |
+
|
| 125 |
+
## Citation
|
| 126 |
+
|
| 127 |
+
```bibtex
|
| 128 |
+
@dataset{electricsheepafrica_oop_health_2025,
|
| 129 |
+
title = {Out-of-Pocket Health Expenditure Dataset},
|
| 130 |
+
author = {Electric Sheep Africa},
|
| 131 |
+
year = {2025},
|
| 132 |
+
url = {https://huggingface.co/datasets/electricsheepafrica/oop-health-expenditure},
|
| 133 |
+
license = {CC-BY-4.0}
|
| 134 |
+
}
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
## License
|
| 138 |
+
|
| 139 |
+
CC-BY-4.0
|
data/oop_high_oop_unprotected.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/oop_low_oop_insured.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/oop_moderate_oop_mixed.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Literature-Informed Out-of-Pocket Health Expenditure Dataset
|
| 4 |
+
=============================================================
|
| 5 |
+
|
| 6 |
+
Each record = ONE household's annual out-of-pocket health spending profile.
|
| 7 |
+
|
| 8 |
+
PHASE 1 — LITERATURE RESEARCH & EVIDENCE SYNTHESIS
|
| 9 |
+
=====================================================
|
| 10 |
+
Sources:
|
| 11 |
+
[1] WHO AFRO (2023). Towards UHC: Tracking Financial Protection in
|
| 12 |
+
the WHO African Region. 150M+ pushed into poverty by OOP; 95M
|
| 13 |
+
making catastrophic payments (>10% of budget) in 2019.
|
| 14 |
+
URL: https://www.afro.who.int/publications/towards-universal-health-coverage
|
| 15 |
+
|
| 16 |
+
[2] WHO AFRO (2023). UHC Day Report. OOP >25% of health spending in
|
| 17 |
+
31 SSA countries; >50% in 11; >70% in 3. Average $35/person/yr.
|
| 18 |
+
Medicines & outpatient care are main drivers. Rural, elderly HH
|
| 19 |
+
heads, multigenerational households most affected.
|
| 20 |
+
URL: https://www.afro.who.int/news/uhc-day-high-health-care-costs
|
| 21 |
+
|
| 22 |
+
[3] WHO GHED (2022). OOP as % current health expenditure (CHE):
|
| 23 |
+
SSA median ~36%. Range: Botswana 5%, South Africa 8%, Rwanda 12%,
|
| 24 |
+
Ghana 37%, Kenya 24%, Nigeria 77%, Chad 66%.
|
| 25 |
+
URL: https://apps.who.int/nha/database/
|
| 26 |
+
|
| 27 |
+
[4] Akazili et al. (2022). Catastrophic health expenditure in SSA:
|
| 28 |
+
systematic review. CHE incidence 1-48% across studies (10% threshold).
|
| 29 |
+
Impoverishment 1-28%. Medicines 40-60% of OOP. DOI: PMC9047424
|
| 30 |
+
|
| 31 |
+
[5] ODI (2023). Health spending in SSA — GHED analysis. Govt health
|
| 32 |
+
expenditure rose 10% in 2020 (pandemic). Most countries <7% of
|
| 33 |
+
budget to health, far below 15% Abuja target.
|
| 34 |
+
URL: https://odi.org/en/insights/what-do-we-know-about-health-spending
|
| 35 |
+
|
| 36 |
+
[6] Exemplars in Global Health (2023). Rwanda CBHI co-payment 10%
|
| 37 |
+
cap, OOP ~12% of CHE. $0.29 flat fee per visit.
|
| 38 |
+
URL: https://www.exemplars.health/topics/primary-health-care/rwanda
|
| 39 |
+
|
| 40 |
+
[7] World Bank (2022). Poverty line: $2.15/day ($785/yr).
|
| 41 |
+
SSA average per-capita health expenditure ~$78.87.
|
| 42 |
+
URL: https://data.worldbank.org
|
| 43 |
+
|
| 44 |
+
PHASE 2 — CAUSAL STRUCTURE (DAG)
|
| 45 |
+
===================================
|
| 46 |
+
ROOT: household_size, ses_quintile, residence, head_age, head_sex,
|
| 47 |
+
insurance_status, chronic_illness_count
|
| 48 |
+
INTERMEDIATE: health_events_12m, care_sought, service_type,
|
| 49 |
+
facility_type, total_cost
|
| 50 |
+
LEAF: oop_spending, oop_category_breakdown, catastrophic_expenditure,
|
| 51 |
+
impoverishment, coping_strategy
|
| 52 |
+
|
| 53 |
+
PHASE 4 — SCENARIOS
|
| 54 |
+
=====================
|
| 55 |
+
1. low_oop_insured: Strong insurance + low OOP (Rwanda-like)
|
| 56 |
+
2. moderate_oop_mixed: Partial insurance (Ghana/Kenya-like)
|
| 57 |
+
3. high_oop_unprotected: Minimal insurance, high OOP (Nigeria/Chad-like)
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
import numpy as np
|
| 61 |
+
import pandas as pd
|
| 62 |
+
import argparse
|
| 63 |
+
import os
|
| 64 |
+
|
| 65 |
+
SCENARIOS = {
|
| 66 |
+
'low_oop_insured': {
|
| 67 |
+
'description': 'Strong insurance, low OOP (Rwanda-like)',
|
| 68 |
+
'exemplar': 'Rwanda/South Africa',
|
| 69 |
+
'oop_pct_che': 0.12, # [3] Rwanda 12%
|
| 70 |
+
'mean_oop_usd': 18, # [2] well below $35 avg
|
| 71 |
+
'sd_oop_usd': 15,
|
| 72 |
+
'insurance_rate': 0.85, # [6] Rwanda >85%
|
| 73 |
+
'catastrophic_10pct_rate': 0.04,# [1] low with insurance
|
| 74 |
+
'impoverishment_rate': 0.03,
|
| 75 |
+
'medicines_share': 0.35, # [4] lower with covered meds
|
| 76 |
+
'outpatient_share': 0.30,
|
| 77 |
+
'inpatient_share': 0.15,
|
| 78 |
+
'transport_share': 0.10,
|
| 79 |
+
'diagnostic_share': 0.10,
|
| 80 |
+
'chronic_prevalence': 0.18,
|
| 81 |
+
'care_seeking_rate': 0.80, # [6] insured 2x utilisation
|
| 82 |
+
},
|
| 83 |
+
'moderate_oop_mixed': {
|
| 84 |
+
'description': 'Partial insurance, moderate OOP (Ghana/Kenya-like)',
|
| 85 |
+
'exemplar': 'Ghana/Kenya',
|
| 86 |
+
'oop_pct_che': 0.36, # [3] SSA median
|
| 87 |
+
'mean_oop_usd': 45, # near SSA average
|
| 88 |
+
'sd_oop_usd': 40,
|
| 89 |
+
'insurance_rate': 0.30,
|
| 90 |
+
'catastrophic_10pct_rate': 0.14,# [4] mid-range
|
| 91 |
+
'impoverishment_rate': 0.10,
|
| 92 |
+
'medicines_share': 0.45, # [4] medicines dominant
|
| 93 |
+
'outpatient_share': 0.25,
|
| 94 |
+
'inpatient_share': 0.12,
|
| 95 |
+
'transport_share': 0.10,
|
| 96 |
+
'diagnostic_share': 0.08,
|
| 97 |
+
'chronic_prevalence': 0.22,
|
| 98 |
+
'care_seeking_rate': 0.55,
|
| 99 |
+
},
|
| 100 |
+
'high_oop_unprotected': {
|
| 101 |
+
'description': 'Minimal insurance, very high OOP (Nigeria/Chad-like)',
|
| 102 |
+
'exemplar': 'Nigeria/Chad',
|
| 103 |
+
'oop_pct_che': 0.72, # [3] Nigeria 77%
|
| 104 |
+
'mean_oop_usd': 80,
|
| 105 |
+
'sd_oop_usd': 70,
|
| 106 |
+
'insurance_rate': 0.05,
|
| 107 |
+
'catastrophic_10pct_rate': 0.28,# [4] high end
|
| 108 |
+
'impoverishment_rate': 0.20,
|
| 109 |
+
'medicines_share': 0.55, # [4] 40-60% medicines
|
| 110 |
+
'outpatient_share': 0.20,
|
| 111 |
+
'inpatient_share': 0.08,
|
| 112 |
+
'transport_share': 0.12,
|
| 113 |
+
'diagnostic_share': 0.05,
|
| 114 |
+
'chronic_prevalence': 0.25,
|
| 115 |
+
'care_seeking_rate': 0.35,
|
| 116 |
+
},
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
SERVICE_TYPES = ['outpatient_consultation', 'inpatient_admission', 'medicines_only',
|
| 120 |
+
'diagnostic_test', 'maternal_care', 'dental_care',
|
| 121 |
+
'chronic_disease_management', 'emergency_care']
|
| 122 |
+
|
| 123 |
+
FACILITY_TYPES = ['public_hospital', 'public_health_centre', 'private_hospital',
|
| 124 |
+
'private_clinic', 'pharmacy', 'traditional_healer', 'none']
|
| 125 |
+
|
| 126 |
+
COPING_STRATEGIES = ['savings', 'borrowing', 'selling_assets', 'reducing_food',
|
| 127 |
+
'community_support', 'delayed_treatment', 'no_coping_needed',
|
| 128 |
+
'forgoing_care']
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def generate_dataset(n=10000, seed=42, scenario='moderate_oop_mixed'):
|
| 132 |
+
rng = np.random.default_rng(seed)
|
| 133 |
+
sc = SCENARIOS[scenario]
|
| 134 |
+
records = []
|
| 135 |
+
|
| 136 |
+
for idx in range(n):
|
| 137 |
+
rec = {'id': idx + 1}
|
| 138 |
+
|
| 139 |
+
# ── ROOT NODES ──────────────────────────────────────────────
|
| 140 |
+
rec['household_size'] = max(1, int(rng.poisson(4.8)))
|
| 141 |
+
rec['ses_quintile'] = int(rng.choice([1, 2, 3, 4, 5],
|
| 142 |
+
p=[0.25, 0.22, 0.20, 0.18, 0.15]))
|
| 143 |
+
rec['residence'] = rng.choice(['urban', 'rural'], p=[0.38, 0.62])
|
| 144 |
+
rec['head_age'] = int(np.clip(rng.normal(40, 14), 18, 85))
|
| 145 |
+
rec['head_sex'] = rng.choice(['male', 'female'], p=[0.62, 0.38])
|
| 146 |
+
|
| 147 |
+
# Insurance status — conditional on scenario & SES
|
| 148 |
+
ins_prob = sc['insurance_rate'] + (rec['ses_quintile'] - 3) * 0.04
|
| 149 |
+
ins_prob = np.clip(ins_prob, 0.01, 0.98)
|
| 150 |
+
rec['has_insurance'] = 1 if rng.random() < ins_prob else 0
|
| 151 |
+
|
| 152 |
+
# Chronic conditions
|
| 153 |
+
rec['chronic_conditions'] = int(rng.poisson(
|
| 154 |
+
sc['chronic_prevalence'] * (1 + (rec['head_age'] - 30) / 80)))
|
| 155 |
+
rec['chronic_conditions'] = min(rec['chronic_conditions'], 5)
|
| 156 |
+
|
| 157 |
+
# Annual household income (USD)
|
| 158 |
+
income_base = {1: 280, 2: 550, 3: 1100, 4: 2400, 5: 5500}
|
| 159 |
+
rec['household_income_usd'] = max(50, int(rng.normal(
|
| 160 |
+
income_base[rec['ses_quintile']],
|
| 161 |
+
income_base[rec['ses_quintile']] * 0.30)))
|
| 162 |
+
|
| 163 |
+
# ── INTERMEDIATE NODES ──────────────────────────────────────
|
| 164 |
+
|
| 165 |
+
# Number of health events in 12 months
|
| 166 |
+
event_lambda = 1.5 + rec['chronic_conditions'] * 0.8
|
| 167 |
+
rec['health_events_12m'] = max(0, int(rng.poisson(event_lambda)))
|
| 168 |
+
|
| 169 |
+
# Care seeking — conditional on insurance, SES
|
| 170 |
+
seek_prob = sc['care_seeking_rate']
|
| 171 |
+
if rec['has_insurance']:
|
| 172 |
+
seek_prob = min(seek_prob + 0.15, 0.95)
|
| 173 |
+
if rec['ses_quintile'] <= 2:
|
| 174 |
+
seek_prob = max(seek_prob - 0.10, 0.10)
|
| 175 |
+
rec['sought_care'] = 1 if (rec['health_events_12m'] > 0 and
|
| 176 |
+
rng.random() < seek_prob) else 0
|
| 177 |
+
|
| 178 |
+
# Service type (most recent episode)
|
| 179 |
+
if rec['sought_care']:
|
| 180 |
+
if rec['chronic_conditions'] > 0 and rng.random() < 0.4:
|
| 181 |
+
rec['primary_service'] = 'chronic_disease_management'
|
| 182 |
+
else:
|
| 183 |
+
svc_p = np.array([0.30, 0.08, 0.25, 0.10, 0.10, 0.02, 0.05, 0.10])
|
| 184 |
+
svc_p = svc_p / svc_p.sum()
|
| 185 |
+
rec['primary_service'] = rng.choice(SERVICE_TYPES, p=svc_p)
|
| 186 |
+
|
| 187 |
+
# Facility type
|
| 188 |
+
if rec['has_insurance']:
|
| 189 |
+
fac_p = np.array([0.30, 0.35, 0.15, 0.10, 0.08, 0.02, 0.0])
|
| 190 |
+
elif rec['ses_quintile'] >= 4:
|
| 191 |
+
fac_p = np.array([0.15, 0.10, 0.30, 0.25, 0.15, 0.05, 0.0])
|
| 192 |
+
else:
|
| 193 |
+
fac_p = np.array([0.15, 0.25, 0.05, 0.10, 0.30, 0.10, 0.05])
|
| 194 |
+
fac_p = fac_p / fac_p.sum()
|
| 195 |
+
rec['facility_type'] = rng.choice(FACILITY_TYPES, p=fac_p)
|
| 196 |
+
else:
|
| 197 |
+
rec['primary_service'] = 'none'
|
| 198 |
+
rec['facility_type'] = 'none'
|
| 199 |
+
|
| 200 |
+
# ── OOP SPENDING CALCULATION ────────────────────────────────
|
| 201 |
+
|
| 202 |
+
rec['oop_total_usd'] = 0.0
|
| 203 |
+
rec['oop_medicines_usd'] = 0.0
|
| 204 |
+
rec['oop_outpatient_usd'] = 0.0
|
| 205 |
+
rec['oop_inpatient_usd'] = 0.0
|
| 206 |
+
rec['oop_transport_usd'] = 0.0
|
| 207 |
+
rec['oop_diagnostic_usd'] = 0.0
|
| 208 |
+
|
| 209 |
+
if rec['sought_care']:
|
| 210 |
+
# Base cost depends on service and facility
|
| 211 |
+
svc_cost_mult = {
|
| 212 |
+
'outpatient_consultation': 1.0, 'inpatient_admission': 5.0,
|
| 213 |
+
'medicines_only': 0.6, 'diagnostic_test': 1.2,
|
| 214 |
+
'maternal_care': 3.0, 'dental_care': 2.0,
|
| 215 |
+
'chronic_disease_management': 1.8, 'emergency_care': 4.0, 'none': 0}
|
| 216 |
+
fac_cost_mult = {
|
| 217 |
+
'public_hospital': 1.0, 'public_health_centre': 0.5,
|
| 218 |
+
'private_hospital': 3.0, 'private_clinic': 2.0,
|
| 219 |
+
'pharmacy': 0.4, 'traditional_healer': 0.3, 'none': 0}
|
| 220 |
+
|
| 221 |
+
base = max(2, rng.lognormal(np.log(sc['mean_oop_usd']), 0.8))
|
| 222 |
+
base *= svc_cost_mult.get(rec['primary_service'], 1.0)
|
| 223 |
+
base *= fac_cost_mult.get(rec['facility_type'], 1.0)
|
| 224 |
+
|
| 225 |
+
# Insurance reduces OOP
|
| 226 |
+
if rec['has_insurance']:
|
| 227 |
+
base *= 0.20 # insurance covers ~80%
|
| 228 |
+
|
| 229 |
+
# Multiple events scale (diminishing)
|
| 230 |
+
base *= (1 + 0.3 * min(rec['health_events_12m'] - 1, 5))
|
| 231 |
+
|
| 232 |
+
total = max(0, base)
|
| 233 |
+
rec['oop_total_usd'] = round(total, 2)
|
| 234 |
+
|
| 235 |
+
# Breakdown by category [4]
|
| 236 |
+
rec['oop_medicines_usd'] = round(total * sc['medicines_share'], 2)
|
| 237 |
+
rec['oop_outpatient_usd'] = round(total * sc['outpatient_share'], 2)
|
| 238 |
+
rec['oop_inpatient_usd'] = round(total * sc['inpatient_share'], 2)
|
| 239 |
+
rec['oop_transport_usd'] = round(total * sc['transport_share'], 2)
|
| 240 |
+
rec['oop_diagnostic_usd'] = round(total * sc['diagnostic_share'], 2)
|
| 241 |
+
|
| 242 |
+
elif rec['health_events_12m'] > 0:
|
| 243 |
+
# Self-medication / pharmacy OOP for those who didn't seek formal care
|
| 244 |
+
# [2] Medicines are primary OOP driver even without formal care
|
| 245 |
+
self_med = max(0, rng.lognormal(
|
| 246 |
+
np.log(sc['mean_oop_usd'] * 0.4), 0.9))
|
| 247 |
+
self_med *= rec['health_events_12m']
|
| 248 |
+
rec['oop_total_usd'] = round(self_med, 2)
|
| 249 |
+
rec['oop_medicines_usd'] = round(self_med * 0.85, 2)
|
| 250 |
+
rec['oop_transport_usd'] = round(self_med * 0.15, 2)
|
| 251 |
+
|
| 252 |
+
# ── LEAF NODES ──────────────────────────────────────────────
|
| 253 |
+
|
| 254 |
+
# Catastrophic health expenditure (>10% of income) [1]
|
| 255 |
+
rec['catastrophic_expenditure'] = 1 if (
|
| 256 |
+
rec['household_income_usd'] > 0 and
|
| 257 |
+
rec['oop_total_usd'] / rec['household_income_usd'] > 0.10) else 0
|
| 258 |
+
|
| 259 |
+
# Impoverishment (pushed below $2.15/day poverty line)
|
| 260 |
+
poverty_line = 785 # $2.15/day * 365
|
| 261 |
+
rec['impoverished_by_oop'] = 1 if (
|
| 262 |
+
rec['household_income_usd'] >= poverty_line and
|
| 263 |
+
(rec['household_income_usd'] - rec['oop_total_usd']) < poverty_line) else 0
|
| 264 |
+
|
| 265 |
+
# OOP as % of income
|
| 266 |
+
rec['oop_pct_income'] = round(
|
| 267 |
+
rec['oop_total_usd'] / max(1, rec['household_income_usd']) * 100, 1)
|
| 268 |
+
|
| 269 |
+
# Coping strategy
|
| 270 |
+
if rec['oop_total_usd'] <= 0:
|
| 271 |
+
rec['coping_strategy'] = 'no_coping_needed'
|
| 272 |
+
elif rec['oop_pct_income'] < 5:
|
| 273 |
+
rec['coping_strategy'] = rng.choice(
|
| 274 |
+
['savings', 'no_coping_needed'], p=[0.4, 0.6])
|
| 275 |
+
elif rec['oop_pct_income'] < 15:
|
| 276 |
+
rec['coping_strategy'] = rng.choice(
|
| 277 |
+
['savings', 'borrowing', 'community_support', 'reducing_food'],
|
| 278 |
+
p=[0.35, 0.30, 0.15, 0.20])
|
| 279 |
+
else:
|
| 280 |
+
rec['coping_strategy'] = rng.choice(COPING_STRATEGIES,
|
| 281 |
+
p=[0.10, 0.25, 0.15, 0.20, 0.05, 0.15, 0.0, 0.10])
|
| 282 |
+
|
| 283 |
+
# Forgone care (didn't seek despite needing)
|
| 284 |
+
rec['forgone_care'] = 1 if (
|
| 285 |
+
rec['health_events_12m'] > 0 and not rec['sought_care']) else 0
|
| 286 |
+
|
| 287 |
+
rec['year'] = rng.choice([2020, 2021, 2022, 2023, 2024],
|
| 288 |
+
p=[0.10, 0.15, 0.20, 0.25, 0.30])
|
| 289 |
+
|
| 290 |
+
records.append(rec)
|
| 291 |
+
|
| 292 |
+
df = pd.DataFrame(records)
|
| 293 |
+
|
| 294 |
+
# ── Summary ─────────────────────────────────────────────────────
|
| 295 |
+
print(f"\n{'='*65}")
|
| 296 |
+
print(f"OOP Health Expenditure — {scenario}")
|
| 297 |
+
print(f" Exemplar: {sc['exemplar']} | n={n} | seed={seed}")
|
| 298 |
+
print(f"{'='*65}")
|
| 299 |
+
seekers = df[df['sought_care'] == 1]
|
| 300 |
+
print(f" Insurance rate: {df['has_insurance'].mean()*100:.1f}%")
|
| 301 |
+
print(f" Care seeking: {df['sought_care'].mean()*100:.1f}%")
|
| 302 |
+
print(f" Mean OOP (seekers): ${seekers['oop_total_usd'].mean():.1f}")
|
| 303 |
+
print(f" Median OOP (seekers): ${seekers['oop_total_usd'].median():.1f}")
|
| 304 |
+
print(f" Catastrophic (>10%): {df['catastrophic_expenditure'].mean()*100:.1f}%"
|
| 305 |
+
f" (target ~{sc['catastrophic_10pct_rate']*100:.0f}%)")
|
| 306 |
+
print(f" Impoverished: {df['impoverished_by_oop'].mean()*100:.1f}%"
|
| 307 |
+
f" (target ~{sc['impoverishment_rate']*100:.0f}%)")
|
| 308 |
+
print(f" Forgone care: {df['forgone_care'].mean()*100:.1f}%")
|
| 309 |
+
return df
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
if __name__ == '__main__':
|
| 313 |
+
parser = argparse.ArgumentParser(
|
| 314 |
+
description='Generate OOP Health Expenditure Dataset')
|
| 315 |
+
parser.add_argument('--all-scenarios', action='store_true')
|
| 316 |
+
parser.add_argument('--n', type=int, default=10000)
|
| 317 |
+
parser.add_argument('--seed', type=int, default=42)
|
| 318 |
+
args = parser.parse_args()
|
| 319 |
+
|
| 320 |
+
os.makedirs('data', exist_ok=True)
|
| 321 |
+
|
| 322 |
+
if args.all_scenarios:
|
| 323 |
+
for sc_name in SCENARIOS:
|
| 324 |
+
df = generate_dataset(n=args.n, seed=args.seed, scenario=sc_name)
|
| 325 |
+
fname = os.path.join('data', f'oop_{sc_name}.csv')
|
| 326 |
+
df.to_csv(fname, index=False)
|
| 327 |
+
print(f" -> Saved to {fname}\n")
|
| 328 |
+
else:
|
| 329 |
+
df = generate_dataset(n=args.n, seed=args.seed)
|
| 330 |
+
df.to_csv(os.path.join('data', 'oop_moderate_oop_mixed.csv'), index=False)
|
| 331 |
+
print(" -> Saved\n")
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy>=1.24
|
| 2 |
+
pandas>=2.0
|
| 3 |
+
matplotlib>=3.7
|
validate_dataset.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Validation & Visualization for OOP Health Expenditure Dataset."""
|
| 3 |
+
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import numpy as np
|
| 6 |
+
import matplotlib.pyplot as plt
|
| 7 |
+
import os
|
| 8 |
+
import glob
|
| 9 |
+
|
| 10 |
+
def load_scenarios(data_dir='data'):
|
| 11 |
+
dfs = {}
|
| 12 |
+
for f in sorted(glob.glob(os.path.join(data_dir, 'oop_*.csv'))):
|
| 13 |
+
basename = os.path.basename(f).replace('.csv', '')
|
| 14 |
+
name = basename[4:] # strip leading 'oop_' prefix only
|
| 15 |
+
dfs[name] = pd.read_csv(f)
|
| 16 |
+
return dfs
|
| 17 |
+
|
| 18 |
+
def main():
|
| 19 |
+
dfs = load_scenarios()
|
| 20 |
+
if not dfs:
|
| 21 |
+
print("No CSV files found in data/. Run generate_dataset.py first.")
|
| 22 |
+
return
|
| 23 |
+
|
| 24 |
+
all_df = pd.concat(
|
| 25 |
+
[df.assign(scenario=name) for name, df in dfs.items()], ignore_index=True)
|
| 26 |
+
|
| 27 |
+
fig, axes = plt.subplots(4, 2, figsize=(16, 20))
|
| 28 |
+
fig.suptitle('Out-of-Pocket Health Expenditure — Validation Report',
|
| 29 |
+
fontsize=14, fontweight='bold', y=0.98)
|
| 30 |
+
colors = {'low_oop_insured': '#2ecc71',
|
| 31 |
+
'moderate_oop_mixed': '#f39c12',
|
| 32 |
+
'high_oop_unprotected': '#e74c3c'}
|
| 33 |
+
labels = {'low_oop_insured': 'Low OOP (Rwanda-like)',
|
| 34 |
+
'moderate_oop_mixed': 'Moderate OOP (Ghana/Kenya)',
|
| 35 |
+
'high_oop_unprotected': 'High OOP (Nigeria/Chad)'}
|
| 36 |
+
scenarios = list(dfs.keys())
|
| 37 |
+
|
| 38 |
+
# Panel 1: OOP spending distribution (truncated)
|
| 39 |
+
ax = axes[0, 0]
|
| 40 |
+
for s in scenarios:
|
| 41 |
+
vals = dfs[s].loc[dfs[s]['oop_total_usd'] > 0, 'oop_total_usd'].clip(upper=300)
|
| 42 |
+
if len(vals) > 0:
|
| 43 |
+
ax.hist(vals, bins=50, alpha=0.5, label=labels.get(s, s),
|
| 44 |
+
color=colors[s], density=True)
|
| 45 |
+
ax.set_xlabel('OOP Spending (USD, capped at $300)')
|
| 46 |
+
ax.set_ylabel('Density')
|
| 47 |
+
ax.set_title('Panel 1: OOP Spending Distribution')
|
| 48 |
+
ax.legend(fontsize=7)
|
| 49 |
+
|
| 50 |
+
# Panel 2: Catastrophic expenditure by scenario
|
| 51 |
+
ax = axes[0, 1]
|
| 52 |
+
cat_rates = [dfs[s]['catastrophic_expenditure'].mean() * 100 for s in scenarios]
|
| 53 |
+
targets = [4, 14, 28]
|
| 54 |
+
x = np.arange(len(scenarios))
|
| 55 |
+
ax.bar(x - 0.15, cat_rates, 0.3, label='Observed',
|
| 56 |
+
color=[colors[s] for s in scenarios], alpha=0.8)
|
| 57 |
+
ax.bar(x + 0.15, targets, 0.3, label='Target', color='grey', alpha=0.5)
|
| 58 |
+
ax.set_xticks(x)
|
| 59 |
+
ax.set_xticklabels([labels.get(s, s) for s in scenarios], fontsize=7, rotation=15)
|
| 60 |
+
ax.set_ylabel('Catastrophic Expenditure (%)')
|
| 61 |
+
ax.set_title('Panel 2: Catastrophic Expenditure Rate')
|
| 62 |
+
ax.legend(fontsize=8)
|
| 63 |
+
for i, (o, t) in enumerate(zip(cat_rates, targets)):
|
| 64 |
+
ax.text(i - 0.15, o + 0.5, f'{o:.1f}%', ha='center', fontsize=7)
|
| 65 |
+
|
| 66 |
+
# Panel 3: OOP breakdown by category
|
| 67 |
+
ax = axes[1, 0]
|
| 68 |
+
cats = ['medicines', 'outpatient', 'inpatient', 'transport', 'diagnostic']
|
| 69 |
+
width = 0.25
|
| 70 |
+
for i, s in enumerate(scenarios):
|
| 71 |
+
d = dfs[s]
|
| 72 |
+
seekers = d[d['oop_total_usd'] > 0]
|
| 73 |
+
if len(seekers) == 0:
|
| 74 |
+
continue
|
| 75 |
+
total = seekers['oop_total_usd'].sum()
|
| 76 |
+
shares = [seekers[f'oop_{c}_usd'].sum() / total * 100 for c in cats]
|
| 77 |
+
ax.bar(np.arange(len(cats)) + i * width, shares, width,
|
| 78 |
+
label=labels.get(s, s), color=colors[s], alpha=0.8)
|
| 79 |
+
ax.set_xticks(np.arange(len(cats)) + width)
|
| 80 |
+
ax.set_xticklabels([c.capitalize() for c in cats], fontsize=8)
|
| 81 |
+
ax.set_ylabel('Share of Total OOP (%)')
|
| 82 |
+
ax.set_title('Panel 3: OOP Breakdown by Category')
|
| 83 |
+
ax.legend(fontsize=7)
|
| 84 |
+
|
| 85 |
+
# Panel 4: OOP by SES quintile
|
| 86 |
+
ax = axes[1, 1]
|
| 87 |
+
for s in scenarios:
|
| 88 |
+
means = dfs[s].groupby('ses_quintile')['oop_total_usd'].mean()
|
| 89 |
+
ax.plot(means.index, means.values, 'o-', label=labels.get(s, s),
|
| 90 |
+
color=colors[s], linewidth=2)
|
| 91 |
+
ax.set_xlabel('SES Quintile (1=poorest)')
|
| 92 |
+
ax.set_ylabel('Mean OOP (USD)')
|
| 93 |
+
ax.set_title('Panel 4: Mean OOP by Wealth Quintile')
|
| 94 |
+
ax.legend(fontsize=8)
|
| 95 |
+
|
| 96 |
+
# Panel 5: Coping strategies
|
| 97 |
+
ax = axes[2, 0]
|
| 98 |
+
strats = ['savings', 'borrowing', 'selling_assets', 'reducing_food',
|
| 99 |
+
'community_support', 'delayed_treatment', 'forgoing_care']
|
| 100 |
+
for i, s in enumerate(scenarios):
|
| 101 |
+
d = dfs[s]
|
| 102 |
+
counts = [d['coping_strategy'].value_counts().get(st, 0) / len(d) * 100
|
| 103 |
+
for st in strats]
|
| 104 |
+
ax.bar(np.arange(len(strats)) + i * 0.25, counts, 0.25,
|
| 105 |
+
label=labels.get(s, s), color=colors[s], alpha=0.8)
|
| 106 |
+
ax.set_xticks(np.arange(len(strats)) + 0.25)
|
| 107 |
+
ax.set_xticklabels([s.replace('_', '\n') for s in strats], fontsize=6)
|
| 108 |
+
ax.set_ylabel('Percentage (%)')
|
| 109 |
+
ax.set_title('Panel 5: Coping Strategies')
|
| 110 |
+
ax.legend(fontsize=7)
|
| 111 |
+
|
| 112 |
+
# Panel 6: Cross-scenario key metrics
|
| 113 |
+
ax = axes[2, 1]
|
| 114 |
+
metrics = ['Insurance %', 'Care Seeking %', 'Catastrophic %',
|
| 115 |
+
'Forgone Care %']
|
| 116 |
+
for i, s in enumerate(scenarios):
|
| 117 |
+
d = dfs[s]
|
| 118 |
+
vals = [d['has_insurance'].mean() * 100,
|
| 119 |
+
d['sought_care'].mean() * 100,
|
| 120 |
+
d['catastrophic_expenditure'].mean() * 100,
|
| 121 |
+
d['forgone_care'].mean() * 100]
|
| 122 |
+
ax.bar(np.arange(len(metrics)) + i * 0.25, vals, 0.25,
|
| 123 |
+
label=labels.get(s, s), color=colors[s], alpha=0.8)
|
| 124 |
+
ax.set_xticks(np.arange(len(metrics)) + 0.25)
|
| 125 |
+
ax.set_xticklabels(metrics, fontsize=8)
|
| 126 |
+
ax.set_ylabel('Percentage (%)')
|
| 127 |
+
ax.set_title('Panel 6: Cross-Scenario Key Metrics')
|
| 128 |
+
ax.legend(fontsize=7)
|
| 129 |
+
|
| 130 |
+
# Panel 7: OOP as % of income distribution
|
| 131 |
+
ax = axes[3, 0]
|
| 132 |
+
for s in scenarios:
|
| 133 |
+
vals = dfs[s].loc[dfs[s]['oop_pct_income'] > 0, 'oop_pct_income'].clip(upper=50)
|
| 134 |
+
if len(vals) > 0:
|
| 135 |
+
ax.hist(vals, bins=50, alpha=0.5, label=labels.get(s, s),
|
| 136 |
+
color=colors[s], density=True)
|
| 137 |
+
ax.axvline(10, color='red', linestyle='--', alpha=0.7, label='10% threshold')
|
| 138 |
+
ax.set_xlabel('OOP as % of Income')
|
| 139 |
+
ax.set_ylabel('Density')
|
| 140 |
+
ax.set_title('Panel 7: OOP as % of Household Income')
|
| 141 |
+
ax.legend(fontsize=7)
|
| 142 |
+
|
| 143 |
+
# Panel 8: Correlation heatmap
|
| 144 |
+
ax = axes[3, 1]
|
| 145 |
+
num_cols = ['household_size', 'ses_quintile', 'has_insurance',
|
| 146 |
+
'chronic_conditions', 'oop_total_usd', 'household_income_usd',
|
| 147 |
+
'catastrophic_expenditure', 'forgone_care']
|
| 148 |
+
corr = all_df[num_cols].corr()
|
| 149 |
+
im = ax.imshow(corr, cmap='RdBu_r', vmin=-1, vmax=1, aspect='auto')
|
| 150 |
+
ax.set_xticks(range(len(num_cols)))
|
| 151 |
+
ax.set_yticks(range(len(num_cols)))
|
| 152 |
+
ax.set_xticklabels([c.replace('_', '\n') for c in num_cols], fontsize=5,
|
| 153 |
+
rotation=45, ha='right')
|
| 154 |
+
ax.set_yticklabels([c.replace('_', '\n') for c in num_cols], fontsize=5)
|
| 155 |
+
ax.set_title('Panel 8: Correlation Heatmap')
|
| 156 |
+
fig.colorbar(im, ax=ax, fraction=0.046)
|
| 157 |
+
for i in range(len(num_cols)):
|
| 158 |
+
for j in range(len(num_cols)):
|
| 159 |
+
ax.text(j, i, f'{corr.iloc[i, j]:.2f}', ha='center', va='center',
|
| 160 |
+
fontsize=4.5, color='white' if abs(corr.iloc[i, j]) > 0.5 else 'black')
|
| 161 |
+
|
| 162 |
+
plt.tight_layout(rect=[0, 0, 1, 0.96])
|
| 163 |
+
plt.savefig('validation_report.png', dpi=150, bbox_inches='tight')
|
| 164 |
+
plt.close()
|
| 165 |
+
print("Saved validation_report.png")
|
| 166 |
+
|
| 167 |
+
print("\n=== VALIDATION SUMMARY ===")
|
| 168 |
+
for s in scenarios:
|
| 169 |
+
d = dfs[s]
|
| 170 |
+
seekers = d[d['sought_care'] == 1]
|
| 171 |
+
print(f"\n{labels.get(s, s)}:")
|
| 172 |
+
print(f" Insurance: {d['has_insurance'].mean()*100:.1f}%")
|
| 173 |
+
print(f" Mean OOP (seekers): ${seekers['oop_total_usd'].mean():.1f}")
|
| 174 |
+
print(f" Catastrophic: {d['catastrophic_expenditure'].mean()*100:.1f}%")
|
| 175 |
+
print(f" Forgone care: {d['forgone_care'].mean()*100:.1f}%")
|
| 176 |
+
|
| 177 |
+
if __name__ == '__main__':
|
| 178 |
+
main()
|
validation_report.png
ADDED
|
Git LFS Details
|