# ─── FIGURE 9: Parameter Comparison ──────────────────────────────────────────
fig, axes = plt.subplots(2, 3, figsize=(16, 9))
period_names = [r['Period'] for r in results]
x = np.arange(len(period_names))
width = 0.35
params_to_plot = [
('θ — Long-Run Mean (%)', 'θ_USD', 'θ_KHR'),
('κ — Mean Reversion Speed', 'κ_USD', 'κ_KHR'),
('σ — Volatility', 'σ_USD', 'σ_KHR'),
('Half-Life (months)', 'HL_USD', 'HL_KHR'),
('Avg Crisis Probability', 'P_USD', 'P_KHR'),
]
for idx, (title, col_usd, col_khr) in enumerate(params_to_plot):
ax = axes.flat[idx]
vals_usd = [r[col_usd] for r in results]
vals_khr = [r[col_khr] for r in results]
bars1 = ax.bar(x - width/2, vals_usd, width, label='USD', color='#1565C0', alpha=0.85)
bars2 = ax.bar(x + width/2, vals_khr, width, label='KHR', color='#C62828', alpha=0.85)
ax.set_title(title, fontweight='bold', fontsize=11)
ax.set_xticks(x)
ax.set_xticklabels(period_names, fontsize=9)
ax.legend(fontsize=8)
ax.grid(True, alpha=0.3, axis='y')
for bars in [bars1, bars2]:
for bar in bars:
h = bar.get_height()
ax.annotate(f'{h:.2f}', xy=(bar.get_x()+bar.get_width()/2, h),
xytext=(0, 2), textcoords='offset points', ha='center', va='bottom', fontsize=7)
axes.flat[5].set_visible(False)
fig.suptitle('Figure 9: OU Parameters Across COVID Sub-Periods', fontweight='bold', fontsize=14, y=1.01)
plt.tight_layout()
plt.savefig('../figures/fig9_covid_comparison.png', dpi=300, bbox_inches='tight')
plt.show()
print('Saved: fig9_covid_comparison.png')