CIR with a switching mean level
A square-root intensity whose long-run level follows a regime.
The intensity follows $dx = \kappa(\theta_y - x)\,dt + \sigma\sqrt{x}\,dW$. The coefficient of $x$ in the bond price solves $B' = 1 - \kappa B - \tfrac12\sigma^2 B^2$, which does not involve $\theta$, so the state factors out whenever only the mean level switches:
$$B(t) = \frac{2\,(e^{ht} - 1)}{(h+\kappa)(e^{ht}-1) + 2h}, \quad h = \sqrt{\kappa^2 + 2\sigma^2}, \qquad g_i(t) = -\kappa\,\theta_i\,B(t).$$Here $\kappa = 1.5$, $\theta = (0.08, 0.02)$ and $\sigma = 0.15$. The table gives the error in $a_1(3)$ after each order. $B$ is not a sum of exponentials, so the engine holds $g_i$ as a Chebyshev series.
| switching rate | order 0 | order 1 | order 2 | order 3 | order 4 | order 5 | order 6 |
|---|---|---|---|---|---|---|---|
| 5 | 2.5e-3 | 7.1e-7 | 2.8e-7 | 2.0e-7 | 6.2e-9 | 4.4e-9 | 1.6e-10 |
| 10 | 1.2e-3 | 1.3e-7 | 2.3e-8 | 1.2e-8 | 1.2e-10 | 6.8e-11 | 8.5e-13 |
| 20 | 6.2e-4 | 2.8e-8 | 2.1e-9 | 7.5e-10 | 2.7e-12 | 1.1e-12 | 6.9e-15 |
| 40 | 3.1e-4 | 6.7e-9 | 2.2e-10 | 4.7e-11 | 6.9e-14 | 1.7e-14 | 6.7e-16 |
If $\sigma$ also switched, $B$ would differ between regimes and the state would no longer factor out.