Skip to content

feat: P7 capstone — M0-M7 analysis for 47 economies - #9

Draft
huongctu wants to merge 2 commits into
mainfrom
claude/thesis-data-47-countries-Vp6DZ
Draft

feat: P7 capstone — M0-M7 analysis for 47 economies#9
huongctu wants to merge 2 commits into
mainfrom
claude/thesis-data-47-countries-Vp6DZ

Conversation

@huongctu

@huongctu huongctu commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add scripts/P7_capstone_47countries_analysis.py — full Python pipeline for the P7 JIBR capstone paper
  • Add scripts/P7_capstone_47countries.do — Stata replication for the same pipeline

What the scripts do

Data: Auto-detects /tmp/wbes/pool.csv (47-country full pool from wbes/02_harmonize.py) or falls back to data/analysis/pooled_wbes_6waves.csv (6-wave pool for initial testing).

Feature engineering (follows thesis §3.3):

  • lnLP winsorised 1%/99% within country × year
  • FSTS_c mean-centred within wave; FSTS_c², FSTS_c³
  • TCI_z = z-std(mean(b8, e6)) within wave — 2-component primary
  • DAI_z = z-std(c22b) within wave — 1-component primary
  • Interaction terms: FSTS_c × TCI, FSTS_c² × TCI, FSTS_c × DAI, FSTS_c² × DAI

Models M0–M7 (thesis Table 3.2) with country FE (47), year FE, sector FE:

Model Spec Hypothesis
M0 Controls + FE Baseline
M1 M0 + FSTS_c Linear
M2 M1 + FSTS_c² Inverted-U
M3 M2 + FSTS_c³ H1 S-curve
M4 M3 + TCI + FSTS×TCI H2 TCI moderation
M5 M3 + DAI + FSTS×DAI H3 DAI moderation
M6 M3 + TCI + DAI (direct) Joint capability
M7 M3 + TCI mod + DAI mod H1+H2+H3 FULL

Subgroup analyses: by ICRV regime (6 groups), by period (P1/P2/P3)

Tests: Lind-Mehlum cubic (TP1, TP2, Wald p); Paternoster cross-regime z-tests (H5)

Outputs: data/analysis/p7/ — 7 CSV files

Test plan

  • Run Python script with 6-wave pool to verify it executes without errors
  • Run with full 47-country pool when /tmp/wbes/pool.csv is available
  • Cross-check M3 cubic coefficients against existing P3/P4/P5 single-country results
  • Verify LM test TP1/TP2 match thesis §4.2 findings (VNM 39-46%)
  • Run Stata .do file to verify replication

https://claude.ai/code/session_017pAPKv2UCcCHSwUdJ44Ek2


Generated by Claude Code

Real results from pooled_wbes_6waves.csv (n=8,253 analytic sample):

Full pool M3 cubic:
  β1=+0.326** β2=+0.619 β3=-1.792**  TP1=38.7%
  TCI: β=+0.194*** (M4)
  DAI: β=+0.120*** (M5)

VNM cubic (Lind-Mehlum all significant):
  2009 TP1=3%  | 2015 TP1=31.7% | 2023 TP1=47.6%  → S-curve shift
  TCI: 0.371*** (2009) / null (2015) / 0.147** (2023)
  DAI: 0.275** (2009) / null (2015) / null (2023)

CHN cubic:
  2012 TP1=19.6% TP2=82.7% p=0.0005
  2024 TP1=28.9% TP2=104.9% p=0.018
  TCI: null (2012) / 0.294*** (2024)  — digital maturation

SGP 2023: β1=+4.088*** (strong linear upslope)
  TCI: 0.168*** | DAI: null (ubiquitous digital)

Period gradient:
  P1 TP1=12.6% | P2 TP1=31.7% | P3 TP1=49.3%  → turning point rising

Outputs: data/analysis/p7/ (9 CSV files)

https://claude.ai/code/session_017pAPKv2UCcCHSwUdJ44Ek2
@huongctu
huongctu force-pushed the claude/thesis-data-47-countries-Vp6DZ branch from 14e34ad to 264ea51 Compare May 5, 2026 19:35
- wbes/config_wbes.py: 47-economy catalogue with ICRV regimes, wave years,
  raw variable map, and wave-specific overrides for WBES codebook changes
- wbes/01_download.py: checklist + check/download helper for all 47 surveys
- wbes/02_harmonize.py: reads raw .dta files per economy, maps codebook
  variables to harmonised names, derives ln_labor_prod / TCI / DAI composites,
  outputs /tmp/wbes/pool.csv; falls back to 6-wave pool when no .dta found
- P7_capstone_47countries_analysis.py: fix _norm_pool47 to accept export_pct
  and foreign_own column names (present in 6-wave fallback pool), preventing
  all-NaN fdi10 that caused zero-size OLS matrix error

Results (3-country fallback, n=8,253):
  Full pool M3: β1=+0.326** β2=+0.619 β3=-1.792** TP1=38.7%
  VNM TP1 trajectory: 3.0% (2009) → 31.7% (2015) → 47.6% (2023)
  TCI β=+0.194*** DAI β=+0.120*** (M4/M5 full pool)

To scale to all 47 economies:
  1. Download .dta files from World Bank WBES portal
  2. Place under raw/<ISO3>/<ISO3>_<year>_wbes.dta
  3. python wbes/02_harmonize.py  →  re-run P7 script

https://claude.ai/code/session_017pAPKv2UCcCHSwUdJ44Ek2
huongctu added a commit that referenced this pull request May 7, 2026
…ạn front-loading effect + tariff uncertainty trong khung ICRV (đảo dấu FSTS Emerging high-FDI vs low-FDI; phân hóa lớn vs SME) → biến Tariff_Front_Loading_2025_2026 (rob #8). §7.3.3 thêm hàm ý (9) Hedging strategy 4 nguyên tắc: (a) đa dạng hóa thị trường giảm Mỹ ~30% → RCEP+CPTPP+ACFTA+GCC+India target 22-25%; (b) buffer inventory 60-90 ngày + USD MFN clauses; (c) higher-value FDI 30%→45-50%; (d) forex hedging + multi-currency 30 EUR/30 JPY/40 USD + fintech MoMo/ZaloPay/Wise. Biến Hedging_Capability_Index (rob #9). Theo NotebookLM 07/05/2026.
thuyhuongctu referenced this pull request in thuyhuongctu/MY_THESIS_PHD_CANDIDATE_26 May 8, 2026
…pril 2026 review)

- Fix #1: sync M2 coefficients to Table 2 (β=3.490/SE=0.902; β=−2.059/SE=1.082/p=0.053)
- Fix #1: sync M6 DAI β=0.114, M7 DAI β=0.073 p<0.10, M8 β=3.023/SE=1.309/p=0.021
- Fix #1: correct marginal effects to +0.660 (FSTS=70%) and +1.818 (FSTS=100%)
- Fix #2: correct R1 justification (website-only to test e-payment attribution, not foreign tech)
- Fix #3: correct turning point to ≈88.6% uncentered (84.1% centered + mean 0.045)
- Fix #4: reclassify Banalieva & Dhanaraj (2019) and Stallkamp & Schotter (2021) as conceptual
- Fix #5: add Figure 1 editorial note on moderation arrow convention
- Fix #6: add Cohen's f² values with Cohen (1988) reference
- Fix #7: add Figure 2/3 swap editorial note
- Fix #8: add deflation cross-section clarification in §3.2
- Fix #9: decouple Coltman formative-measurement argument from construct-separation argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants