Global Commodity Shocks, International Trade Linkages, and Economic Resilience: Causal Impacts and Predictive Modelling of Sectoral Stress
This repository investigates how global commodity shocksβincluding energy, food, and metal price volatilityβpropagate through international trade networks and affect sectoral stress and economic resilience. By analyzing trade linkages with major partners such as the U.S., China, the EU, and Gulf economies, the study identifies causal pathways through which external shocks impact agriculture, manufacturing, energy-intensive industries, and exports. Predictive modeling techniques are applied to quantify vulnerabilities and assess resilience under different shock scenarios.
Global commodity volatility can create cascading effects in domestic economies, especially through trade networks. This project integrates high-frequency commodity price data, detailed bilateral trade flows, causal inference methods, and predictive machine learning models to:
- Understand how external shocks transmit through trade linkages.
- Forecast sector-level vulnerabilities using time-series neural networks and gradient boosting.
- Develop policy-relevant resilience metrics for key economic sectors.
Unlike prior work, which often focuses on aggregate effects or isolated shocks, this study combines multiple data dimensions to provide a granular, integrated view of shock propagation and sectoral resilience.
- Global commodity prices (energy, food, metals): World Bank Pink Sheet
- Bilateral trade flows: UN Comtrade
- Sectoral output and value-added: MOSPI
- Exchange rates and macroeconomic controls: RBI database
- Partner-country macro indicators: OECD.Stat and IMF Direction of Trade Statistics
-
Data Collection and Preprocessing
- Aggregate commodity prices, trade flows, and sectoral output.
- Identify major trade partners and sector-specific exposures.
-
Causal Inference
- Use instrumental variables and synthetic control methods to identify causal transmission channels.
- Map the effect of commodity shocks on sectoral performance.
-
Predictive Modeling
- Apply machine learning methods such as tree-based models and gradient boosting to forecast sectoral stress.
- Evaluate model performance using standard metrics (RMSE, MAE, RΒ², MAPE).
-
Resilience Assessment
- Develop quantitative metrics to assess sectoral resilience under varying shock scenarios.
- Analyze which sectors are most vulnerable and where trade linkages amplify or dampen shocks.
A consolidated results document for the "Global Commodity Shocks and Trade Networks" project summarizes all findings, diagnostics, causal estimates, and visualizations.
Key High-Level Takeaways:
- Team: StatGeeks (Aaron T. Mathew, Preetham VJ, Akarsh T, Anirudh K) β Date: November 2025
- Core Finding: Structural distribution shifts (pre-/post-2020 COVID and Ukraine shock) materially affect predictive generalization; causal and network analyses identify critical chokepoints (Petroleum, Trade) and policy-targetable vulnerable sectors.
- Dataset: Unified master dataset (3,476 rows Γ 93 variables), production network (~131 sectors, ~3,401 edges).
- Sprint 1 (Data & Network): Constructed complete I-O derived network with technical coefficients, Leontief inverse matrices, and centrality measures.
- Sprint 2 (Causal Analysis): IV analysis confirmed energy shocks cause ~4.81% IIP decline (10% price increase); identified network bottlenecks via Betweenness Centrality and shock multiplier effects (>2x systemic amplification).
- Sprint 3 (Modeling & Policy): Tree-based models (tuned Random Forest / XGBoost) proved most robust to distribution shifts; Causal ML identified heterogeneous treatment effects across sectors; policy recommendations target Top 5β7 vulnerable sectors for maximum marginal benefit.
For full methodological details, statistical tables, and comprehensive figures, consult the consolidated "Project Results Document" in the deliverables folder or project archive.
global-trade-shocks-analysis/
β
βββ README.md
βββ requirements.txt
βββ .gitignore
β
βββ data/
β βββ raw/ # Original downloaded data (never modify)
β β βββ CMO-Historical-Data-Monthly.xlsx
β β βββ IMTSTrade.csv
β β βββ WITS-Partner.xlsx
β β βββ IndexofIndustrialProduction.xlsx
β β βββ WholesalePriceIndexMonthlyData.xlsx
β β βββ GDP_Constant.xlsx
β β βββ GDP_Current.xlsx
β β βββ GVA_Current.xlsx
β β βββ OECD_file.csv
β β
β βββ processed/ # Cleaned, transformed data
β β βββ proc_cmo_monthly.csv # Commodity prices with shocks
β β βββ climate_oni_clean.csv # Climate indices (ONI)
β β βββ trade_india_bilateral.csv # Bilateral trade flows
β β βββ country_mapping.csv # ISO3 codes and regions
β β βββ iso_dataset_enriched.csv # Trade data with ISO codes
β β βββ iip_sectoral.csv # Industrial production indices
β β βββ wpi_inflation.csv # Wholesale price inflation
β β βββ gdp_quarterly.csv # GDP with growth rates
β β βββ global_macro.csv # OECD G20 data
β β βββ MOSPI Matrix Final - ALL.csv # Input-Output matrix
β β βββ MOSPI_Cleaned_non_matrix.xlsx # I-O non-matrix data
β β βββ master_dataset.csv # Complete merged dataset
β β βββ master_dataset_filtered.csv # Filtered (2010-2024)
β β βββ full_ml_dataset.csv # ML-ready dataset with engineered features
β β βββ master_dataset_columns.csv # Metadata
β β
β βββ processed_io_data/ # Network analysis outputs
β β βββ technical_coefficients.csv
β β βββ leontief_inverse.csv
β β βββ production_network_nodes.csv
β β βββ production_network_edges.csv
β β βββ network_metrics.csv
β β
β βββ external/ # Third-party datasets (if any)
β βββ data-dictionary.md # Data documentation
β
βββ networks/ # Network graph objects
β βββ trade_network_full.gpickle
β βββ trade_network_full.graphml
β βββ trade_network_energy.gpickle
β βββ trade_network_energy.graphml
β βββ trade_network_food.gpickle
β βββ trade_network_food.graphml
β βββ trade_network_metals.gpickle
β βββ trade_network_metals.graphml
β βββ production_network.gpickle
β βββ production_network.graphml
β βββ centrality_degree.csv
β βββ centrality_betweenness.csv
β βββ centrality_closeness.csv
β βββ centrality_eigenvector.csv
β βββ centrality_pagerank.csv
β βββ centrality_all.csv
β βββ network_topology_metrics.csv
β βββ commodity_network_stats.csv
β βββ trade_network.gephi # Gephi project file
β
βββ src/ # Source code (Python scripts)
β βββ __init__.py
β β
β βββ data_collection/
β β βββ __init__.py
β β βββ download_worldbank.py # World Bank data fetcher
β β
β βββ data_processing/
β β βββ __init__.py
β β βββ clean_data.py # Complete data cleaning pipeline
β β βββ create_master_dataset.py # Master dataset creation
β β βββ clean_commodity_prices.py # Commodity price cleaning
β β βββ README.md # Data processing documentation
β β
β βββ network_analysis/
β β βββ __init__.py
β β βββ process_io_table.py # I-O table processing & network metrics
β β βββ build_trade_network.py # Trade network construction
β β βββ visualize_networks.py # Network visualization utilities
β β
β βββ causal_inference/
β β βββ __init__.py
β β βββ instrumental_variables.py
β β βββ synthetic_control.py
β β βββ var_granger.py
β β βββ causal_utils.py
β β
β βββ feature_engineering/
β β βββ __init__.py
β β βββ extract_network_features.py
β β βββ create_lag_features.py
β β βββ create_volatility_features.py
β β βββ create_shock_indicators.py
β β βββ create_interaction_features.py
β β βββ feature_selection.py
β β
β βββ models/
β β βββ __init__.py
β β βββ baseline_models.py
β β βββ lstm_model.py
β β βββ xgboost_model.py
β β βββ gnn_model.py
β β βββ ensemble_model.py
β β βββ model_evaluation.py
β β βββ model_utils.py
β β
β βββ scenario_analysis/
β β βββ __init__.py
β β βββ historical_scenarios.py
β β βββ counterfactual_scenarios.py
β β βββ policy_interventions.py
β β βββ vulnerability_index.py
β β
β βββ visualization/
β β βββ __init__.py
β β βββ plot_networks.py
β β βββ plot_causal_results.py
β β βββ plot_model_results.py
β β βββ plot_scenarios.py
β β βββ viz_utils.py
β β
β βββ dashboard/
β βββ __init__.py
β βββ app.py # Main Streamlit app
β βββ pages/
β β βββ 1_Home.py
β β βββ 2_Networks.py
β β βββ 3_Predictions.py
β β βββ 4_Scenarios.py
β βββ components/
β βββ __init__.py
β βββ network_viz.py
β βββ prediction_viz.py
β βββ scenario_viz.py
β
βββ notebooks/ # Jupyter notebooks for exploration & development
β βββ README.md # Notebook overview and usage guide
β βββ s1_DataCleaning.ipynb # Sprint 1: Data cleaning and EDA
β β βββ Purpose: Exploratory cleaning steps, outlier handling, temporal alignment.
β β Outputs: Insights fed into src/data_processing/clean_data.py
β β
β βββ s1_IOTableProcessing.ipynb # Sprint 1: I-O table processing
β β βββ Purpose: Technical coefficients, Leontief inverse, network metrics (degree, betweenness, PageRank).
β β Outputs: Network CSV exports, feed into src/network_analysis/process_io_table.py
β β
β βββ s1_CreateMasterDataset.ipynb # Sprint 1: Master dataset creation & feature engineering
β β βββ Purpose: Merge all processed data, I-O sector mapping (22 manufacturing sectors),
β β derive interaction terms, lagged variables for econometric analysis.
β β Outputs: data/processed/master_dataset.csv (3,476 rows Γ 93 cols)
β β
β βββ s2_CausalAnalysis.ipynb # Sprint 2: Causal inference (IV, Synthetic Control, VAR)
β β βββ Purpose: Instrumental Variables (2SLS) with ONI & OPEC quotas;
β β Synthetic Control for shock events (2008, 2014, 2022);
β β VAR/Granger Causality & Impulse Response Analysis.
β β Outputs: Causal estimates, IRF plots, robustness checks
β β
β βββ s2_NetworkDynamics.ipynb # Sprint 2: Network resilience & bottleneck analysis
β β βββ Purpose: Shock propagation simulations, centrality-vulnerability linkages,
β β production network dynamics under targeted sector failures.
β β Outputs: Shock multiplier estimates, network robustness metrics
β β
β βββ s3_FeatureEngineering.ipynb # Sprint 3: Advanced feature engineering
β β βββ Purpose: Create lag features, volatility measures, shock indicators,
β β interaction terms; dimensionality reduction (150+ β 50 features).
β β Outputs: Feature importance rankings, engineered datasets
β β
β βββ s3_TreeBasedModels.ipynb # Sprint 3: Tree-based predictive models
β β βββ Purpose: End-to-end ML pipeline:
β β - Target capping (2Ο outlier handling)
β β - Train/test split diagnostics (temporal coherence)
β β - Feature scaling (StandardScaler)
β β - Baseline models (Mean, Linear Regression)
β β - Random Forest baseline & hyperparameter tuning (RandomizedSearchCV)
β β - XGBoost baseline & tuning with early stopping
β β - Feature importance analysis (RF vs XGB comparison)
β β - Weighted ensemble optimization
β β - Comprehensive error analysis (sector-level, temporal, residuals)
β β - Distribution shift diagnostics (KS test, train vs test)
β β Outputs: Model artifacts (pkl), comparison tables, diagnostic plots
β β
β βββ s3_CausalML.ipynb # Sprint 3: Causal Machine Learning (Heterogeneous Effects)
β βββ Purpose: Causal Forests, R-learner, S-learner for heterogeneous treatment effects;
β vulnerability classification; policy targeting optimization.
β Outputs: CATE distributions, policy benefit frontier
β
βββ models/ # Saved trained models
β βββ baseline_ols.pkl
β βββ baseline_rf.pkl
β βββ lstm_energy.h5
β βββ lstm_manufacturing.h5
β βββ lstm_agriculture.h5
β βββ lstm_services.h5
β βββ lstm_exports.h5
β βββ xgboost_main.pkl
β βββ xgboost_tuned.pkl
β βββ gnn_production.pt
β βββ gnn_trade.pt
β βββ ensemble_stacked.pkl
β βββ model_metadata.json
β
βββ outputs/ # All output files (models, figures, tables)
β βββ models/ # Trained model artifacts
β β βββ linear_regression_baseline.pkl
β β βββ random_forest_baseline.pkl
β β βββ random_forest_tuned.pkl
β β βββ xgboost_baseline.pkl
β β βββ xgboost_tuned.pkl
β β
β βββ figures/ # Publication-quality visualizations
β β βββ target_distribution_analysis.png
β β β βββ Raw vs 2Ο-capped histograms & boxplots
β β βββ feature_importance_comparison.png
β β β βββ Side-by-side top-30 features: Random Forest vs XGBoost
β β βββ model_comparison.png
β β β βββ Multi-panel comparison (RΒ², RMSE, MAE, MAPE) across all models
β β βββ sector_predictions.png
β β β βββ Time-series actual vs predicted for top-5 sectors
β β βββ sector_error_analysis.png
β β β βββ Top sectors by MAE & error vs sample size
β β βββ temporal_error_analysis.png
β β β βββ MAE and bias trends over time (year-quarter)
β β βββ residual_diagnostics.png
β β β βββ Residuals vs predicted, histogram + normal overlay, Q-Q, time series
β β βββ distribution_shift_analysis.png
β β β βββ Train vs Test overlapping histograms, boxplots, CDFs
β β βββ (additional sector-specific and network plots as generated)
β β
β βββ tables/ # CSV, LaTeX, and summary tables
β β βββ model_comparison.csv
β β β βββ RMSE, MAE, RΒ², MAPE for all models
β β βββ feature_importance.csv
β β β βββ Feature rankings from RF, XGB, and ensemble
β β βββ sector_error_analysis.csv
β β β βββ MAE, Std, Max Error, Bias per sector
β β βββ temporal_error_analysis.csv
β β β βββ Error metrics by year-quarter
β β βββ distribution_shift_summary.csv
β β β βββ Train vs Test statistics (mean, std, min, max, KS test)
β β βββ (additional causal, network, and scenario tables)
β β
β βββ data_quality/ # Data validation reports
β βββ commodity_prices_validation.txt
β βββ trade_data_validation.txt
β βββ master_dataset_summary.txt
β βββ missing_values_report.csv
β
βββ sprint_3_output/ # Sprint 3 experiment-specific outputs
β βββ target_distribution_analysis.png
β βββ feature_importance_comparison.png
β βββ (other intermediate or exploratory artifacts)
β
βββ sprint3_opts/ # Alternative tuning experiment outputs
β βββ models/ # Model snapshots from different tuning runs
β βββ (other experiment-specific files)
β
βββ docs/ # Documentation
β βββ data_sources.md
β βββ data_dictionary.xlsx
β βββ master_dataset_dictionary.xlsx
β βββ feature_dictionary.xlsx
β βββ mospi_io_processing_notes.md
β βββ methodology_notes.md
β βββ api_usage_guide.md
β βββ troubleshooting.md
β
βββ presentations/ # Presentation materials
β βββ sprint1_review.pptx
β βββ sprint2_review.pptx
β βββ sprint3_review.pptx
β βββ final_presentation.pptx
β βββ poster.pdf # Optional conference poster
β
βββ reports/ # Written reports
β βββ drafts/
β β βββ sprint1_summary.docx
β β βββ sprint2_causal_analysis.docx
β β βββ sprint3_model_results.docx
β βββ final_report.pdf
β βββ final_report.docx
β βββ executive_summary.pdf
β βββ policy_brief.pdf
β
βββ tests/ # Unit tests (optional but recommended)
β βββ __init__.py
β βββ test_data_processing.py
β βββ test_network_analysis.py
β βββ test_models.py
β βββ test_utils.py
β
βββ logs/ # Log files
βββ data_download.log
βββ model_training.log
βββ error.log
linear_regression_baseline.pklrandom_forest_baseline.pklβ Baseline Random Forestrandom_forest_tuned.pklβ Best tree-based model (RΒ² β 0.017)xgboost_baseline.pklxgboost_tuned.pklβ Tuned XGBoost (RΒ² β 0.011)
Distribution & Target Analysis:
target_distribution_analysis.pngβ Raw vs 2Ο-capped histograms & boxplotsdistribution_shift_analysis.pngβ Train vs Test overlap plots, CDF comparison
Model Performance:
model_comparison.pngβ Multi-metric bar charts (RΒ², RMSE, MAE, MAPE)feature_importance_comparison.pngβ Top-30 features from RF & XGB side-by-side
Error Diagnostics:
sector_predictions.pngβ Time-series actual vs predicted for top-5 sectorssector_error_analysis.pngβ MAE rankings and error vs sample sizetemporal_error_analysis.pngβ MAE & bias trends by year-quarterresidual_diagnostics.pngβ Residuals vs predicted, histogram, Q-Q, time series
model_comparison.csvβ RMSE, MAE, RΒ², MAPE for all modelsfeature_importance.csvβ RF, XGB, and average importance rankingssector_error_analysis.csvβ Per-sector MAE, std, bias, sample sizetemporal_error_analysis.csvβ Per-quarter MAE, bias, sample sizedistribution_shift_summary.csvβ Train/test statistics & KS test results
sprint_3_output/β Experiment-specific artifacts (e.g., target distribution plots)sprint3_opts/models/β Alternative tuning run snapshots
To rebuild all cleaned and processed datasets from raw files:
# Install dependencies
pip install -r requirements.txt
# Run the full cleaning pipeline
python src/data_processing/clean_data.py
# Process I-O tables and calculate network metrics
python src/network_analysis/process_io_table.py
# Create master dataset and export
python src/data_processing/create_master_dataset.pyAll outputs saved to data/processed/ and data/processed_io_data/.
Each notebook is self-contained and documents its purpose in the header:
jupyter notebook notebooks/s3_TreeBasedModels.ipynb
# (or any other notebook)Notebooks import data from data/processed/ and write outputs to outputs/ and/or sprint_3_output/.
- Model comparison:
outputs/tables/model_comparison.csv - Feature importance:
outputs/tables/feature_importance.csv - Model artifacts:
outputs/models/*.pkl - Visualizations:
outputs/figures/
The project identified a significant structural break between training (pre-2020: volatile, COVID-affected) and test (post-2020: recovery) periods, confirmed by Kolmogorov-Smirnov test. This explains why:
- Linear models failed (RΒ² β β36)
- Tree-based models were more robust (tuned RF: RΒ² β 0.017)
- Deep learning (LSTM) overfitted β learned high-volatility patterns that don't apply to stable test period
- Energy shocks: 10% oil price increase β β4.81% IIP (all manufacturing: β8.0%), p < 0.05
- Food shocks: wheat prices showed negative coefficient (β2.55) but not statistically significant (p > 0.05)
- Instruments validated: Sargan-Hansen test p-values > 0.05 (exogeneity confirmed)
- Critical bottlenecks: Petroleum Products, Trade, Electricity (ranked by Betweenness Centrality)
- Shock multiplier: 10% output shock β 2.19x cumulative impact via Leontief propagation
- Scale-free topology: Robust to random failures, vulnerable to targeted attacks on top ~15% central nodes
- Targeting strategy: Policy Benefit Frontier is concave β diminishing returns beyond Top 5β7 sectors
- Expected benefit: Mitigation strategy could preserve 0.46% of aggregate IIP growth during shock
- High-vulnerability sectors: Other Manufacturing, Tobacco, Electrical Equipment
- Most resilient sectors: Motor Vehicles, Pharmaceuticals, Basic Metals
- Aaron Thomas Mathew β GitHub
- Preetham VJ β GitHub
- Akarsh T β GitHub
- Anirudh Krishnan β GitHub
-
Global Supply Chain Reallocation and Shift under Triple Crises: A U.S.-China Perspective
https://arxiv.org/pdf/2508.06828 -
Financial Markets, Financial Institutions, and International Trade: Examining the Causal Links for Indian Economy
https://arxiv.org/pdf/2112.01749 -
The Causal Effects of Commodity Shocks
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5219522 -
Leontief Model & Input-Output Analysis for Supply Chain Shock Propagation
https://mitpress.mit.edu/
This project is provided for educational purposes as part of the ADA course project (UE23AM343AB1).
Last Updated: November 2025