Additional File 6  ·  Methodological Supplement

Algorithmic Pipeline: ML-based G-Computation for Heterogeneous Wealth-Associated Counterfactual Odds Ratios

Sudarshan Saha & Sohel Rana  ·  East West University, Dhaka, Bangladesh  ·  BDHS 2022 Cross-Sectional Survey

1
Data preparation & sample construction
Source: BDHS 2022 Individual Recode (IR) file — BDIR81FL.SAV  ·  DHS Phase 8
Exclusion sequence
30,078 women aged 15–49All interviewed respondents
→
28,537 currently marriedV501 = 1
→
11,528 extreme quintilesV190 ∈ {1, 5}
→
11,510 analytic sample−18 missing any covariate
Variable coding — all 10 variables
RoleDHS variableLabelCodingNotes
Outcome (Y)V312Modern contraceptive useBinary: 1 = modern method; 0 = otherwise. Codes: 1,2,3,5,6,10,11,14DHS-8 standard definition
Exposure (A)V190Household wealth quintileBinary: 1 = richest (V190=5); 0 = poorest (V190=1)Extreme quintiles only; middle 3 excluded
CovariateV012Age in completed yearsContinuous → standardised; grouped 15–24, 25–34, 35–49 for subgroup analysisStandardScaler applied
CovariateV106Educational attainment4 categories: none / primary / secondary / higherDHS standard grouping
CovariateV025Urban/rural residenceBinary: urban = 1, rural = 0
CovariateV136Household sizeContinuous → standardisedStandardScaler applied
CovariateV201Parity (children ever born)Continuous → standardised; capped at 10Strongest SHAP predictor (mean |ϕ| = 0.4113)
CovariateV714Current employment statusBinary: employed = 1Proxy for economic independence
CovariateV158Media exposure (TV)Binary: any TV watching = 1 (V158 > 0; includes < once/week through almost every day)FP message exposure proxy; note: code uses V158 > 0, capturing all non-zero response categories
CovariateV632FP decision autonomyBinary: woman has say = 1 (V632 ∈ {1, 2})Contraceptive autonomy proxy
Preprocessing steps
Rationale for extreme-quintile restriction: Maximises exposure contrast for the counterfactual estimand and reduces positivity violations. Only 52.7% of the full wealth distribution falls within the 0.1–0.9 propensity score overlap range. Findings explicitly do not generalise to the middle three quintiles (~60% of currently married Bangladeshi women).
2
Causal identification & DAG assumptions
Potential outcomes framework (Rubin 1974)  ·  G-computation (Robins 1986)  ·  Estimand: stratum-level counterfactual contrast
Estimand — individual counterfactual OR
Individual counterfactual OR for woman i: OR_i = [ μ̂₁(Xᵢ) / (1 − μ̂₁(Xᵢ)) ] ÷ [ μ̂₀(Xᵢ) / (1 − μ̂₀(Xᵢ)) ] where μ̂ₐ(Xᵢ) = P̂(Y = 1 | Xᵢ, A = a) for a ∈ {0 = poorest, 1 = richest} Interpretation: counterfactual ratio of odds of modern contraceptive use for woman i under richest vs. poorest wealth quintile assignment, given her observed covariate profile Xᵢ. This is a stratum-level contrast, not an individual wealth manipulation.
Three identifying assumptions
DAG — covariate roles
Common causes (confounders)
Age, educational attainment, urban/rural residence, household size — included in all models
Mediator treated as confounder
Household size — potential mediator on wealth→contraceptive path; included to close backdoor paths
Unmeasured confounders (dashed nodes)
Partner preferences; geographic method availability — sensitivity quantified via E-values
Positivity verification summary
PS overlap region [0.1, 0.9]
52.7% of sample
Minimum cell size (12 age × education strata)
Total n ≥ 30 per subgroup cell (code checks total n, consistent with §2.11 wording — not split per wealth stratum)
Untrimmed max stabilised IPTW weight
218.56
Untrimmed effective sample size (ESS)
8.7%
3
T-learner model training — six model classes
Two separate outcome models per class: μ̂₁ on richest stratum (n = 6,296) and μ̂₀ on poorest stratum (n = 5,214)
T-learner training structure
Complete hyperparameter specifications — all six model classes
Model classFull hyperparameter specificationCV-AUCBrier scoreOR SD
Logistic Regression (LR) Parametric benchmark penalty='l2', C=1.0, solver='lbfgs', max_iter=1000, tol=1e-4, fit_intercept=True, class_weight=None, random_state=42 0.69370.22700.328
Random Forest (RF) n_estimators=300, max_depth=6, min_samples_leaf=20, min_samples_split=2, max_features='sqrt', bootstrap=True, n_jobs=-1, random_state=42 0.70120.22640.171
Gradient Boosting (GB) Selected for subgroup analysis n_estimators=200, learning_rate=0.05, max_depth=4, subsample=0.8, min_samples_leaf=1, max_features=None, random_state=42. Loss: deviance (log-loss). No early stopping. 0.70980.22611.212
XGBoost (XGB) n_estimators=200, learning_rate=0.05, max_depth=4, subsample=0.8, colsample_bytree=0.8, reg_alpha=0, reg_lambda=1, eval_metric='logloss', random_state=42 0.70850.22620.829
LightGBM (LGB) n_estimators=200, learning_rate=0.05, max_depth=4, num_leaves=31, subsample=0.8, colsample_bytree=0.8, reg_alpha=0, reg_lambda=0, random_state=42. Tree growth: leaf-wise (histogram-based splitting). 0.70900.22630.934
Stacking Ensemble No SHAP · No bootstrap CI Base learners (reduced specs for computational feasibility): LR (same as primary), RF (n_estimators=200, max_depth=5, min_samples_leaf=20), GB (n_estimators=150, lr=0.05, max_depth=4), XGB (n_estimators=150, lr=0.05, max_depth=4), LGB (n_estimators=150, lr=0.05, max_depth=4). Meta-learner: Logistic Regression (L2, C=1.0). Out-of-fold predictions from 5-fold CV used to train meta-learner. 0.71080.22590.373
Class imbalance handling: None applied. Outcome prevalence = 34.9% — above the 10–15% minority-class threshold commonly used to trigger SMOTE, oversampling, or class-weight adjustment. class_weight=None in all models.
Software environment
Python
3.12
scikit-learn
1.6.1
XGBoost
3.2.0
LightGBM
4.6.0
SHAP
Latest stable (TreeExplainer)
Preprocessing
StandardScaler (sklearn)
GB model selection rationale (four criteria)
Model calibration
4
G-computation — individual OR estimation
Stratified parametric g-formula (Robins 1986) implemented via T-learner (Künzel et al. 2019, PNAS)
Step-by-step algorithmic procedure
Gini coefficient of |log ORᵢ|: Gini = 0.4525 Bootstrap 95% CI (1,000 individual-level resamples): [0.4475, 0.4568] Interpretation: the top 10% of women (by |log OR|) account for 29.0% of total absolute log-OR mass — high concentration of wealth effect in a minority of demographic subgroups. Key subgroup ARDs (GB model): 35–49 / Higher education: median ARD = +17.6 pp (IQR: +11.4 to +23.6 pp) 15–24 / Primary education: median ARD = −11.3 pp (IQR: −16.6 to −5.6 pp) 25–34 / Higher education: median ARD = +13.5 pp (IQR: +4.7 to +18.9 pp)
Relationship to other CATE estimators
EstimatorAsymptotically valid CIs for individual CATEs?Binary outcome native?Role in this study
T-learner g-computationNo — bootstrap CIs for subgroup medians onlyYes (OR estimand)Primary estimator
AIPW (doubly-robust)Yes (ATE only, not individual)Yes (risk difference)Sensitivity check for ATE direction
Causal forest (Wager & Athey 2018)Yes (asymptotically valid)No — risk difference nativeRecommended for future work
DR-learner (Kennedy 2023)Yes (doubly-robust)PartialRecommended for future work
Bootstrap CI scope: PSU-level bootstrap CIs (200 resamples) quantify sampling uncertainty in subgroup median ORs arising from the complex two-stage BDHS cluster design. They are NOT asymptotically valid CIs for individual-level CATE estimates — cross-fitted DR-learner or causal forest estimators would be required for the latter.
5
Subgroup inference & uncertainty quantification
PSU-level stratified bootstrap (200 resamples) · BH-FDR correction · Likelihood-ratio interaction tests
PSU-level bootstrap protocol
Survey weight limitation: DHS design weights (sampling weights) were NOT incorporated into ML model fitting — a non-trivial methodological extension requiring careful treatment of PSU-level clustering in the T-learner framework. The PSU-level bootstrap partially accounts for clustered sampling uncertainty. Unweighted ML fitting may bias absolute prevalence estimates but is unlikely to alter the structure of OR heterogeneity, since covariate-specific probability contrasts are relatively robust to moderate survey weight misspecification.
Likelihood-ratio interaction tests — pre-specified primary hypotheses
Interaction termLR χ²dfp-valueSignificant (α = 0.05)?FDR corrected?
Wealth × Education8.34830.039YesNo — pre-specified primary hypothesis
Wealth × Age group10.64220.005YesNo — pre-specified primary hypothesis
Wealth × Residence2.66610.103NoNo — pre-specified primary hypothesis
Interaction tests compare logistic regression models with and without the specified wealth × modifier interaction terms. These are pre-specified primary hypotheses and are NOT subject to BH-FDR correction (which applies only to the 12 age × education subgroup cell comparisons).
Multiple comparisons correction — BH-FDR
Absolute risk difference (ARD) computation
For individual i: ARD_i = μ̂₁(Xᵢ) − μ̂₀(Xᵢ) Cell-level summary: median ARD (pp) with IQR across all i in that subgroup cell. Positive values: richest-quintile women have higher predicted mCP prevalence. Negative values: poorest-quintile women have higher predicted mCP prevalence. Note: At observed prevalence levels > 30%, ORs diverge from risk ratios — programme planners should consult the ARD column for absolute-scale interpretation.
6
Sensitivity & robustness analyses
AIPW doubly-robust ATE · E-value analysis · Three robustness checks
AIPW doubly-robust ATE estimator
AIPW influence function for observation i: ψᵢ = [ μ̂₁(Xᵢ) + Aᵢ(Yᵢ − μ̂₁(Xᵢ)) / ê(Xᵢ) ] −[ μ̂₀(Xᵢ) + (1−Aᵢ)(Yᵢ − μ̂₀(Xᵢ)) / (1 − ê(Xᵢ)) ] ATE_AIPW = n⁻¹ Σᵢ ψᵢ where ê(Xᵢ) = P̂(A = 1 | Xᵢ) is the propensity score estimated by logistic regression with all 8 covariates. Doubly-robust property: consistent if EITHER the outcome model OR the propensity score model is correctly specified.
PS trimming and covariate balance
AIPW robustness check — RF propensity score
Specification: RF PS model: n_estimators=200, max_depth=5, min_samples_leaf=20, random_state=42. All 5 non-RF outcome models yielded near-null AIPW estimates (p = 0.20–0.89) under the RF propensity score, confirming the doubly-robust property. The RF outcome model's significance (p = 0.02) under the RF propensity score reflects RF's propensity to overfit the outcome probability surface, not a genuine nonzero ATE.
E-value analysis (VanderWeele & Ding 2017, Ann Intern Med)
E-value formula: For OR ≥ 1: E = OR + √[ OR × (OR − 1) ] For OR < 1: First compute 1/OR, then apply above formula. E-value = minimum OR-scale association an unmeasured confounder would need to have with BOTH exposure AND outcome simultaneously to fully explain away the observed association. Strongest finding — 35–49 / Higher education: Median OR = 3.557 E-value (point estimate) = 6.572 E-value (IQR lower bound, 25th pct) = 3.551 Classification: Strong (E ≥ 3) Additional strong findings (E ≥ 3): 15–24 / Primary (OR = 0.552): E-value = 3.024 25–34 / Higher (OR = 2.308): E-value = 4.045
Three robustness checks
CheckModification from primary analysisResultConclusion
Alternative trimming thresholdIndividual ORs trimmed at 95th percentile instead of primary 99th percentileMedian OR shift = 0.000 across all 12 age × education cells (Supplementary Table S3)Fully robust — findings not driven by extreme observations
Restricted childbearing-age sampleExclude women aged 45–49; n = 9,847Results nearly identical to primary analysisElevated OR in older higher-educated women is not an artefact of including post-reproductive-prime women
Alternative exposure definitionWealth dichotomised at median (above vs. below) instead of extreme quintiles; n = 28,519Substantial heterogeneity qualitatively preserved; subgroup ORs attenuated relative to extreme-quintile analysisExpected attenuation from reduced exposure contrast; higher-education urban pattern preserved
7
SHAP decomposition & programmatic output
Exact SHAP TreeExplainer — predictive attribution only, not causal effects · Programmatic targeting table
SHAP computation protocol
Critical caveat — SHAP ≠ causal effects: SHAP values decompose variation in the predicted probability of modern contraceptive use. They quantify predictive contributions to the outcome model, NOT causal effects of each covariate on contraceptive use. Furthermore, individual ORs are ratios of two T-learner probability surfaces — SHAP applied to the pooled model cannot be directly translated to the individual OR distribution. The SHAP ranking identifies which covariates most strongly moderate the predicted outcome probability, not which have the largest causal impact.
SHAP feature importance ranking (mean |ϕⱼ|)
RankFeatureDHS variableMean |ϕⱼ|Direction (beeswarm)
1Parity (children ever born)V2010.4113Higher parity → lower predicted mCP probability
2Currently employedV7140.3683Employed → higher predicted mCP probability
3Age in yearsV0120.3324Older age → higher predicted mCP probability
4FP decision autonomyV6320.2087Has say → higher predicted mCP probability
5Urban/rural residenceV0250.1424Urban → mixed direction by education stratum
6Household sizeV1360.1191Larger household → lower predicted mCP probability
7Educational attainmentV1060.0495Higher education → higher predicted mCP probability
8Media exposure (TV watching)V1580.0098Any TV → slightly higher predicted mCP probability
Programmatic targeting framework — four-tier classification
High priority — OR ≥ 3.0
35–49 / Higher education (n = 791, OR = 3.557, ARD = +17.6 pp, E-value = 6.57)
Recommended action: subsidised LARC insertion at public urban tertiary facilities; insurance benefit packages covering private-sector long-acting methods; means-tested voucher programmes.
Moderate priority — OR 1.5–2.9
25–34 / Higher (n = 1,103, OR = 2.308, ARD = +13.5 pp) and 15–24 / Higher (n = 586, OR = 1.544, ARD = +5.7 pp)
Recommended action: targeted demand generation; outreach to urban professional women on public-sector LARC alternatives.
Low priority — OR 0.8–1.4
35–49 / Secondary (OR = 1.239), 35–49 / Primary (OR = 1.173), 25–34 / No education (OR = 0.883), 15–24 / No education (OR = 0.838)
Recommended action: near-equitable access — monitor trends; maintain existing community supply chain.
Equity achieved — OR < 0.8
15–24 / Primary (OR = 0.552), 25–34 / Primary (OR = 0.803), 15–24 / Secondary (OR = 0.758), 35–49 / No education (OR = 0.816)
Recommended action: sustain community-based injectable and oral pill distribution programmes — wealth not a barrier in these subgroups.
Tier threshold caveat: Cutpoints (OR < 0.8; 0.8–1.4; 1.5–2.9; ≥ 3.0) are post-hoc decision-analytic boundaries aligned with natural breaks in the observed OR distribution — not statistically derived thresholds. Programme planners should adapt these to local context, resource constraints, and operational priorities. All findings apply to currently married women in the two extreme wealth quintiles only and should not be extrapolated to the middle three quintiles.