Replication Data and Code for “Digital Connectivity, Productive Capacity, and Trade Openness in Africa: A Machine Learning Approach”
Description
This dataset supports the study titled “Digital Connectivity, Productive Capacity, and Trade Openness in Africa: A Machine Learning Approach.” The study examines how digital connectivity, productive capacity, infrastructure, and macroeconomic conditions predict trade openness across African economies. The repository contains the harmonised dataset and Python code used for the empirical analysis. The data cover 54 African countries from 1985 to 2024, producing a balanced country-year panel of 2,160 observations. The main outcome variable is trade openness, measured as trade as a percentage of GDP. The predictors include internet use, mobile subscriptions, access to electricity, GDP per capita, GDP growth, foreign direct investment inflows, industry value added, services value added, inflation, and population density. The accompanying Python notebook reproduces the machine learning workflow used in the study. The analysis estimates Elastic Net, Random Forest, Extra Trees, Gradient Boosting, and HistGradientBoosting models. Model performance is assessed using a random train-test split, repeated-split validation, and a temporal holdout test. The repository also supports the permutation importance analysis, principal component analysis, and K-means clustering used to identify country-level digital-trade readiness regimes. The files are shared to support transparency, replication, and further research on digital connectivity, productive capacity, and trade openness in Africa. The data were drawn from publicly available World Development Indicators sources and processed for the purpose of this study.
Files
Steps to reproduce
Download all repository files into one working folder. Open the Python notebook named Topic_01_Digital_Trade_Openness.ipynb in Jupyter Notebook, JupyterLab, VS Code, or Google Colab. Place the Excel file named Topic_01_data.xlsx in the same folder as the notebook. If the Excel file has a different name, update the DATA_FILE line in the notebook to match the file name. Install the required Python packages before running the notebook: pandas, numpy, matplotlib, scikit-learn, openpyxl. Run the notebook cells from top to bottom without skipping any cell. The notebook first loads the World Development Indicators panel from the Data sheet in the Excel file. It then prepares the target variable, trade as a percentage of GDP, and the ten predictors used in the study. The notebook estimates the machine learning models: Elastic Net, Random Forest, Extra Trees, Gradient Boosting, and HistGradientBoosting. It reports model performance using random train-test split, repeated-split validation, and temporal holdout validation. It generates the interpretation outputs, including permutation feature importance, principal component analysis, and K-means clustering. All generated tables, figures, and model outputs are saved in the outputs folder created by the notebook.
Institutions
- University of Cape CoastCentral, Cape Coast