$ ⌘K
// playbooks / military-coup-prediction · drc_coup_analysis

DRC Coup Analysis — Full Pipeline

step_count: 13· runtime: 5-10 minutes

End-to-end pipeline capturing the data acquisition, merging, ingestion, and analysis workflow used to analyze coup dynamics in the Democratic Republic of Congo. Acquires Powell & Thyne coup events and World Bank WDI indicators, merges into a country-year panel, ingests into Praxis, validates, and runs bivariate and multivariate models. Developed during an April 2026 analytical session.

// pipeline
13 steps· DAG
01

Acquire Powell & Thyne coup event data

action data_acquire
config (7 keys)
{
  "entity_id_column": "country",
  "entity_id_convention": "country_name",
  "format": "tsv",
  "notes": "Each row is a coup event, NOT a country-year. Column 'coup': 1=successful, 2=attempted/failed. Column 'ccode' is the COW country code. Must be collapsed to country-year panel with binary coup_attempt indicator. Version field tracks dataset updates (e.g., V2026.01.13).",
  "quality_notes": "Coverage: 1950-2025, 497 events across 97 countries. Some historical country names need standardization (e.g., 'Democratic Republic of the Congo' vs 'Zaire'). DRC coding note: 1960 and 1965 coups coded as type=2 (failed) which may be incorrect for 1965 Mobutu coup — see issue #208.",
  "source_url": "https://www.uky.edu/~clthyn2/coup_data/powell_thyne_coups_final.txt",
  "year_column": "year"
}
02

Acquire World Bank GDP per capita and growth data

action data_acquire
config (3 keys)
{
  "entity_id_convention": "iso3",
  "notes": "World Bank uses ISO3 codes (e.g., COD for DRC). No registration required. Data updated annually around February.",
  "sources": [
    {
      "format": "api_json",
      "id": "wdi_gdp_pcap",
      "notes": "GDP per capita in constant 2015 USD. Paginated JSON — set per_page=20000 to get all records in one call. Filter out aggregate entities (keep only ISO3 codes).",
      "url": "https://api.worldbank.org/v2/country/all/indicator/NY.GDP.PCAP.KD?format=json\u0026per_page=20000\u0026date=1950:2025"
    },
    {
      "format": "api_json",
      "id": "wdi_gdp_growth",
      "notes": "GDP growth annual %. Same API pattern. Null values are common for early years and small states.",
      "url": "https://api.worldbank.org/v2/country/all/indicator/NY.GDP.MKTP.KD.ZG?format=json\u0026per_page=20000\u0026date=1950:2025"
    }
  ]
}
03

Build country-year panel from coup events

action data_merge
config (3 keys)
{
  "description": "Transform Powell \u0026 Thyne event data into a country-year panel. For each country with any coup event, create rows for every year 1950-2025.",
  "notes": "Panel should have ~7,000 rows (97 countries × ~75 years). Some countries enter the panel late (post-independence).",
  "outputs": {
    "coup_attempt": "Binary: 1 if any coup event in that country-year, else 0",
    "coup_history_count": "Running count of prior coup attempts up to (but not including) current year",
    "coup_success": "Binary: 1 if a successful coup (type=1) in that country-year, else 0"
  }
}
04

Merge WDI data onto coup panel

config (6 keys)
{
  "crosswalk": "Powell \u0026 Thyne uses country names and COW codes. WDI uses ISO3. Need COW-to-ISO3 mapping. Key mappings: DRC=490/COD, Congo-Brazzaville=484/COG. A comprehensive crosswalk covers ~90% of countries; ~7 COW codes may not match and should be logged as warnings.",
  "edge_cases": "WDI data starts 1960 (not 1950). GDP growth starts 1961. Expect ~5,300 matched rows out of ~6,800 panel rows. Missing GDP data is concentrated in early years and conflict periods — this is informative missingness, not random.",
  "join_keys": [
    "country_name",
    "year"
  ],
  "left": "coup_country_year_panel",
  "merge_strategy": "left_join",
  "right": "wdi_indicators"
}
05

Ingest WDI indicators into Praxis

action data_ingestmerge_wdi_onto_panel
config (7 keys)
{
  "construct_mapping": {
    "gdp_growth": "economic_growth_shock",
    "gdp_per_capita": "gdp_per_capita_coup"
  },
  "entity_column": "country",
  "entity_type": "country",
  "format": "long",
  "notes": "Use praxis_ingest_data with the merged panel JSON file. Expected: ~10,600 observations inserted across 2 constructs.",
  "source_id": "world_bank_wdi_2026",
  "year_column": "year"
}
06

Ingest coup indicators into Praxis

action data_ingestbuild_country_year_panel
config (7 keys)
{
  "construct_mapping": {
    "coup_attempt": "coup_attempt",
    "coup_history_count": "coup_history",
    "coup_success": "coup_success"
  },
  "entity_column": "country",
  "entity_type": "country",
  "format": "long",
  "notes": "Expected: ~20,500 observations across 3 constructs. All country-years get values (0 for no-coup years).",
  "source_id": "powell_thyne_dataset_2025",
  "year_column": "year"
}
07

Validate ingested data

action data_validateingest_wdi_data, ingest_coup_data
config (5 keys)
{
  "checks": [
    "coup_attempt values are 0 or 1 only",
    "coup_success values are 0 or 1 only",
    "gdp_per_capita_coup \u003e 0 where not null",
    "DRC entity exists: 'Democratic Republic of the Congo'",
    "DRC has GDP data from 1960 onward"
  ],
  "entity_count_min": 90,
  "expected_constructs_with_data": 5,
  "expected_total_observations_min": 30000,
  "year_range": [
    1950,
    2025
  ]
}
08

DRC GDP per capita trend

action analyzevalidate_panel
config (2 keys)
{
  "construct_x": "gdp_per_capita_coup",
  "entity_id": "Democratic Republic of the Congo"
}
09

Bivariate: GDP per capita → coup attempt

action analyzevalidate_panelcompare_to_kb
config (2 keys)
{
  "construct_x": "gdp_per_capita_coup",
  "construct_y": "coup_attempt"
}
10

Bivariate: Economic growth → coup attempt

action analyzevalidate_panelcompare_to_kb
config (2 keys)
{
  "construct_x": "economic_growth_shock",
  "construct_y": "coup_attempt"
}
11

Bivariate: Coup history → coup attempt

action analyzevalidate_panelcompare_to_kb
config (2 keys)
{
  "construct_x": "coup_history",
  "construct_y": "coup_attempt"
}
12

Multivariate logistic regression: coup prediction

action run_enginebivariate_gdp_coup, bivariate_growth_coup, bivariate_history_coupon fail: continuecompare_to_kb
config (2 keys)
{
  "outcome": "coup_attempt",
  "predictors": [
    "gdp_per_capita_coup",
    "economic_growth_shock",
    "coup_history"
  ]
}
expected results (3 keys)
{
  "coup_history": {
    "direction": "positive"
  },
  "economic_growth_shock": {
    "direction": "negative"
  },
  "gdp_per_capita_coup": {
    "direction": "negative"
  }
}
13

Full correlation matrix

action run_enginevalidate_panel
config (1 key)
{
  "variables": [
    "coup_attempt",
    "coup_success",
    "coup_history",
    "gdp_per_capita_coup",
    "economic_growth_shock"
  ]
}
// from pax
Military Coup Prediction
// engines
engine.logistic_regressionengine.correlation_matrix
// note
step bodies extracted from the .pax archive at build time. download the parent pax for the full yaml.
[ download military-coup-prediction.pax.tar.gz ]