This repository implements a multi-source data integration and PCA-based analysis of global quality-of-life indicators, combining economic, social, and governance metrics from the World Bank, IMF, IEP (Institute for Economics & Peace), Numbeo, and World Sports Rankings datasets.
The goal is to quantify and visualize how countries differ and evolve across time in a common multidimensional space.
Published on iROZHLAS.cz (in Czech) as an article by Jan Boček Jakou cestu Češi od 90. let urazili a jsme blíž Západu, či Východu? ‚Směr je dobrý,‘ věří výzkumník
Co se stane, když nasbíráme čtyři desítky statistických ukazatelů o rozvinutých zemích – od HDP po počet sexuálních partnerů – a země automaticky roztřídíme? Vznikne graf, který připomíná mapu Evropy. Češi mají nejblíž k Italům a Slovincům, od Němců jsou stejně vzdálení jako od Slováků.
These are data acquisition and preprocessing scripts for individual data sources.
Each produces harmonized CSVs with the same structure:
Country, Year, and one or more indicator columns.
All country names are normalized to World Bank naming conventions.
| Script | Purpose / Source |
|---|---|
00_data_preprocessor_IEP.R |
Loads and reshapes IEP (Institute for Economics & Peace) indicators such as Global Peace Index and Positive Peace Index. |
00_data_preprocessor_IMF.R |
Processes IMF indicators such as debt, GDP ratios, and government finance statistics. |
00_data_preprocessor_worldbank360_social_benefits.py |
Extracts Social Benefits (% of GDP) from World Bank 360 datasets. |
00_data_prepreprocessor_WB.R |
Loads World Bank indicators listed in 2025_timedata/worldbank/ according to mapping defined in qualityoflife_sourcedesc.xlsx in 2025datadesc and countries lists . Countries list selects only those wanted. |
00_data_preprocessor_numbeo_houseprice.py |
Fetches and processes Numbeo House Price to Income Ratio data. |
00_data_preprocessor_worldbank360_press_freedom.py |
Extracts the Press Freedom Index Rank from World Bank 360 data. |
00_data_preprocessor_scraper_Worldsportrankings.R |
Scrapes World Sports Ranking dataset and converts it to a comparable format (Country, Year, Points). |
Integrates all harmonized sources above into a single unified table
qualityoflife_merged.csv
with columns:
Country, Year, and all numeric indicators.
This is the master dataset for downstream analysis.
Performs Principal Component Analysis (PCA) using the latest available values for each indicator and each country (≤ selected cutoff year).
- Allows manual filtering of countries and indicators.
- Missing values are replaced by column means.
- Saves PCA model (rotation, center, scale) and scores to:
PCAmodel/pca_model_<year>.rdsPCAmodel/pca_scores_<year>_pc12.csvPCAmodel/pca_loadings_<year>_pc12.csv
Projects each country’s temporal trajectory (1995–2025) into the PCA space created by the previous script.
The script:
- Uses LOCF + NOCB (Last Observation Carried Forward + Next Observation Carried Backward) to fill missing years,
- Computes path metrics:
- total path length (sum of yearly displacements),
- net displacement (start → end),
- directionality (net / total path),
- angle (direction in PC1–PC2 space),
- Outputs trajectory CSV and plot in the
trajectory/folder.
Older diagnostic script testing loading stability of each indicator across years and their contribution to PC1 and PC2.
Partly replaced by the new optimized PCA approach.
The optimized PCA selector – a more advanced alternative to 02_PCA.
It automatically selects a non-redundant, high-variance subset of indicators.
Main adjustable parameters:
max_na_ratio– allowed fraction of missing values (0.5 = keep columns with ≤50% NA).
→ Use1.0to keep everything.corr_threshold– correlation cutoff (0.97 typical).
→ Higher = keep more correlated variables.min_features/max_features– range of selected indicators.
Example:
max_na_ratio <- 0.7
corr_threshold <- 0.98
min_features <- 10
max_features <- 25Outputs are saved into:
PCAmodel_opt_simple/pca_model_opt_simple_<year>.rds- corresponding
pca_scores/pca_loadingsCSVs and PNGs.
Equivalent to 03_time_progression_in_existing_space.R but works with the optimized PCA model (script 05).
Automatically reconstructs centering and scaling if not stored in the RDS.
Generates the same trajectory metrics and figure in trajectory/.
| Folder | Contents |
|---|---|
PCAmodel/ |
PCA models and scores generated by 02_PCA_based_on_last.R. |
PCAmodel_opt_simple/ |
Models from optimized PCA (script 05). |
PCAoutput/ |
Graphical PCA results and biplots. |
trajectory/ |
Temporal trajectories of countries (PC1–PC2 paths, metrics, plots). |
2025_timedata/ |
Raw or preprocessed source datasets by domain (World Bank, IMF, IEP, Numbeo, etc.). |
This repository builds a cross-domain composite index using PCA to:
- Integrate economic, social, and institutional indicators from multiple public datasets,
- Explore country differentiation and temporal dynamics in a unified space,
- Support reproducible, script-based analyses in R and Python.
📄 Download this README:
👉 Download README.md