back to portfolio
case study · count models · poisson & negative binomial · MLE from scratch

Petrostates & Conflict Initiation

Do oil-rich leaders start wars to survive at home? Drawing on my own research, this project models the number of militarized interstate disputes a country initiates each year as a function of coup risk and petrostate status — using Poisson and negative-binomial regression built from the likelihood up, and an interactive dashboard for the central interaction.

Python · numpy / pandaspeacesciencer + Haber-Menaldo Poisson IRLSNegative Binomial MLEOverdispersionInteractive
5,610
country-years, 1960–2010 (2,117 petrostate-years), non-democracies
86%
of country-years see zero MID initiations — a rare, zero-heavy count
α=1.49
negative-binomial overdispersion — the data demand more than Poisson allows

// the argument

Petrostates behave more aggressively abroad than other states. My theory locates the cause not in oil wealth alone, but in the strategic position of vulnerable leaders. When a leader faces a credible internal threat — a high coup risk — oil revenue gives them the means to start interstate conflicts that coup-proof the regime: co-opting the military with budgets and missions, rallying the public around nationalism, and buying time to repress opposition. Conflict initiation, on this account, is a tool of domestic survival.

central hypothesis

Coup risk raises the rate of MID initiation, and the effect is amplified in petrostates, whose oil income removes the budget constraint on diversionary conflict — a petrostate × coup-risk interaction.

// data & measurement

The unit is the country-year, 1960–2010, restricted to non-democracies (Polity < 7). The outcome is the count of militarized interstate disputes a state initiates in a year (Correlates of War / UCDP via the peacesciencer package). Coup risk follows Belkin & Schofer / Sudduth (2017); oil dependence is fuel income as a share of GDP from Haber & Menaldo's fiscal-reliance data (petrostate = fuel ≥ 10% of GDP); controls cover fuel exports, military spending, GDP per capita, and ongoing civil war. The pipeline ships a calibrated simulation so it runs offline; flip USE_REAL_DATA to load the merged panel.

def poisson_irls(X, y):
    """log E[y] = Xβ via iteratively reweighted least squares (= Newton for a GLM)."""
    beta = np.zeros(X.shape[1]); beta[0] = np.log(y.mean())
    for _ in range(100):
        mu = np.exp(np.clip(X @ beta, -30, 30))   # mean = variance (Poisson)
        z  = (X @ beta) + (y - mu) / mu           # working response
        W  = mu                                    # IRLS weights
        beta = np.linalg.solve((X*W[:,None]).T @ X, (X*W[:,None]).T @ z)
    return beta

// why count models

MID initiation is a count: a non-negative integer, mostly zero, occasionally several. Ordinary regression would predict negative and fractional conflicts and mis-state the uncertainty. The Poisson model fixes the support by modelling the log rate, but it assumes the mean equals the variance — and conflict data are far more dispersed than that, with a glut of zeros and a long right tail.

Figure 1 · Observed MID counts vs. a Poisson fit at the mean. The excess of zeros and the heavy tail signal overdispersion.
Figure 1 · Observed MID counts vs. a Poisson fit at the mean. The excess of zeros and the heavy tail signal overdispersion.

A Pearson dispersion of 1.30 (> 1) confirms it, so I also fit a negative binomial, which adds a parameter α so the variance can exceed the mean (Var = μ + αμ²). It fits substantially better on AIC — the inference below uses it.

// interactive · simulate a regime

The widget runs the fitted negative-binomial model in your browser. Set a country's oil dependence and controls, then watch how its predicted conflict rate rises with coup risk — and how the petrostate and non-petrostate curves diverge. The dot marks the coup-risk level you select.

predicted MIDs / year
P(≥1 MID this year)
petrostate (fuel ≥ 10%) non-petrostate your selected coup risk
Predicted rate uses the from-scratch negative-binomial coefficients; P(≥1 MID) = 1 − (1+αμ)−1/α from the NB(0) probability. All computed client-side — no server, no libraries.

// results · the models

Both estimators agree on the story. Higher coup risk and petrostate status each raise the rate of conflict initiation, and the interaction is positive: the marginal effect of coup risk is larger for petrostates. Coefficients are reported as incidence-rate ratios (eβ) — the multiplicative change in the expected MID count.

# Negative binomial: Var = μ + αμ²  (α>0 absorbs the overdispersion)
def loglik(theta):
    beta, alpha = theta[:-1], np.exp(theta[-1]); r = 1/alpha
    mu = np.exp(np.clip(X @ beta, -30, 30))
    return np.sum(gammaln(y+r) - gammaln(r) - gammaln(y+1)
                  + r*np.log(r/(r+mu)) + y*np.log(mu/(r+mu)))
# maximized by Newton-Raphson + line search -> α = 1.49, beats Poisson on AIC
Table 1 · Negative-binomial regression · DV = MID initiations (count) · α = 1.49
termcoefIRR = eβstd. errzp95% CI (IRR)
(intercept)-2.2430.1060.062-36.100.000*0.09–0.12
coup risk+0.5651.7600.05410.480.000*1.58–1.96
petrostate+0.7352.0860.1275.790.000*1.63–2.67
petrostate × coup risk+0.2901.3360.0773.770.000*1.15–1.55
fuel export share+0.9962.7080.4122.420.016*1.21–6.08
military spending (z)+0.0681.0710.0930.740.4590.89–1.28
log GDP/capita (z)-0.1710.8430.032-5.280.000*0.79–0.90
ongoing civil war+0.5061.6580.1034.920.000*1.35–2.03
log-lik = -2715.1 · * p < .05, + p < .10 · IRR > 1 → more conflict
Figure 2 · Negative-binomial incidence-rate ratios. Petrostate status, coup risk, and their interaction all push conflict up.
Figure 2 · Negative-binomial incidence-rate ratios. Petrostate status, coup risk, and their interaction all push conflict up.
Table 2 · Poisson estimates (for comparison)
termcoefIRRstd. errzp95% CI (IRR)
(intercept)-2.2500.1050.056-40.230.000*0.09–0.12
coup risk+0.5741.7760.04712.240.000*1.62–1.95
petrostate+0.7232.0600.1056.910.000*1.68–2.53
petrostate × coup risk+0.2311.2600.0593.900.000*1.12–1.42
fuel export share+1.1683.2150.3113.750.000*1.75–5.92
military spending (z)+0.0531.0550.0770.690.4890.91–1.23
log GDP/capita (z)-0.1580.8540.026-6.170.000*0.81–0.90
ongoing civil war+0.5301.6990.0776.880.000*1.46–1.98
Poisson understates standard errors under overdispersion — hence the negative binomial above

// the central finding · the interaction

The interaction is the heart of the argument. For a non-petrostate, rising coup risk nudges conflict up modestly. For a petrostate, the same rise in coup risk produces a far steeper climb — oil revenue converts domestic vulnerability into the capacity for diversionary war. This is the pattern behind cases like Iraq under Saddam Hussein and revolutionary Iran.

Figure 3 · Predicted MID initiations vs. coup risk, petrostates vs. non-petrostates — the central interaction, and the engine of the dashboard above.
Figure 3 · Predicted MID initiations vs. coup risk, petrostates vs. non-petrostates — the central interaction, and the engine of the dashboard above.
Figure 4 · Model-predicted vs. observed initiation rate across the coup-risk distribution.
Figure 4 · Model-predicted vs. observed initiation rate across the coup-risk distribution.
Table 3 · model comparison
modellog-likkAICdispersion
Poisson-2850.285716.41.30
Negative Binomial-2715.195448.21.00
the negative binomial wins on AIC and resolves the overdispersion the Poisson cannot

// what this demonstrates