1Say what makes a term structure model affine, and write Vasicek, CIR and G2++ in the one form.
2Derive the Riccati ODEs for A(τ) and B(τ) from the pricing PDE.
3Explain why affine dynamics give affine yields, and read a model's yield loadings.
4Solve the Riccati equations by RK4 and check the result against a closed form.
Why it matters
Module 5.3 priced zero-coupon bonds in three models, each with its own formula: Vasicek (L5.3.02: The Vasicek model), Cox-Ingersoll-Ross (L5.3.03: The CIR model) and G2++ (L5.3.10: Two-factor models). Put the three side by side and they have one shape: the exponential of a number minus a weighted sum of the model's random factors. That is not luck. It is one rule, set out by Duffie and Kan in 1996, and it turns bond pricing in a whole family of models into two ordinary differential equations. This module uses the family on seventeen years of the Bank of England's curve; this lesson builds the machine.
Real curveIllustrative dataSterling OIS, 31 December 2025
The curve is the level's one rates market: the Bank of England's fitted OIS curve at 31 December 2025 (L5.2.02: Bootstrapping a curve) real. Module 5.3's models on it stand as booked: Vasicek and CIR with their vol set at 90bp of normal vol illustrative and κ and θ fitted to the curve derived, and G2++ fitted to Module 5.2's illustrative swaption vols, so illustrative too (L5.3.10: Two-factor models) illustrative. This page reads no history. Every figure is a model on that one day's curve, and every check compares a numerical solution with a closed form, so the checks are arithmetic, not market facts.
Three ingredients
A model describes today's market by a few numbers, its state vectorState vector: the few numbers x = (x₁, …, x_N) that, with the model's parameters, fix every bond price today. In Vasicek and CIR it is the short rate; in G2++ the two factors. x. It is affineAffine: a constant plus a linear term, a + bᵀx. A model is affine when the short rate, the drift and the variance of the state are all affine in the state. when three things are a constant plus a linear term in x:
the short rate, r = δ₀ + δ₁ᵀx;
the drift of x under the pricing measure ℚ, K(θ − x);
the variance of x's shocks: each shock i has variance αᵢ + βᵢᵀx, scaled by a matrix Σ.
Nothing else is assumed. The variance ingredient is what separates the members. In Vasicek it is a constant (α = 1, β = 0): a Gaussian model. In CIR it is proportional to the rate itself (α = 0, β = 1): the square-root process of L5.3.03: The CIR model. G2++ has two Gaussian factors. Written in the one form:
Module 5.3's fits, unchanged: Vasicek and CIR to the curve's zero rates, G2++ to the illustrative swaption grid. The class label is Dai and Singleton's A_m(N): N factors, m of them in the variance (L5.4.03: Multi-factor affine models).
Model
State x
Short rate
Drift K(θ − x)
Variance of shocks
Class
Vasicek
r
r = x
κ = 0.0549, θ = 5.752%
σ² = (90bp)², constant
A0(1)
CIR
r
r = x
κ = 0.0457, θ = 6.141%
σ²r, σ = 0.0466
A1(1)
G2++
(x, y)
r = φ + x + y
a = 8.435, b = 0.0230, θ = 0
σ = 10.65%, η = 0.961%, ρ = −0.724, constant
A0(2)
Hull-White and Ho-Lee are affine too: their θ(t) lets the drift's constant change with time, which keeps it affine in r. G2++ in Module 5.3 had a time-varying shift φ(t) fitted to the curve; here φ is held at a constant, which changes the level of every yield but not how yields respond to the factors. illustrative
Sort itAffine or not?
Sort each model by whether all three ingredients are affine in its state.
Vasicek: dr = κ(θ − r)dt + σdW
CIR: dr = κ(θ − r)dt + σ√r dW
Hull-White: dr = (θ(t) − ar)dt + σdW
Black-Karasinski: d ln r = (θ(t) − a ln r)dt + σdW
A rate with volatility proportional to the rate: dr = κ(θ − r)dt + σr dW
From a PDE to two ODEs
A bond is the ℚ-average of its discount factor, and Feynman-Kac turns that average into a partial differential equation in the state and time (M-F05: PDEs and the Feynman-Kac link). For an affine model, guess a price that is exponential-affineExponential-affine: of the form exp(A − Bᵀx). Bond prices in an affine model have this form, so log prices and yields are affine in the state., P = exp(A(τ) − B(τ)ᵀx), where τ is the time to maturity. Put the guess into the PDE and divide by P. Because the drift and the variance are affine in x, what is left is a constant plus a vector times x. The PDE has to hold at every state, so both must vanish. That gives one ODE for the vector B(τ) and one for the number A(τ), both starting from zero at τ = 0. The B equation is quadratic in B, a Riccati equationRiccati equation: a first-order ODE that is quadratic in the unknown, dy/dτ = q₀ + q₁y + q₂y². In affine models B solves one; its square comes from the variance term. (M-B06: Differential equations). The walkthrough in the formal version does it line by line.
Check it on the one-factor models. Vasicek has β = 0, so B′ = 1 − κB: the linear mean-reversion equation, solved by B = (1 − e−κτ)/κ. CIR has β = 1, so B′ = 1 − κB − ½σ²B², the Riccati equation of M-B06: Differential equations's third worked example. A then needs no new solving: A′ is a known function of B, so A is an integral.
Affine dynamics give affine yields
Take logs and divide by τ: the τ-year zero yield is y(τ) = −A(τ)/τ + (B(τ)/τ)ᵀx. Every yield is a fixed intercept plus fixed loadingsYield loading: B(τ)/τ, how many basis points the τ-year yield moves per basis point of a factor. In an affine model it does not depend on the state. times the factors, and the loadings do not depend on where the state is. In the G2++ fit the 10-year yield loads 0.8932 on the slow factor and only 0.0119 on the fast one. Move the slow factor from −1% to 2% in steps of 1% and the 10-year yield goes 2.010%, 2.903%, 3.796%, 4.689%: equal steps of 89.32bp. That small fast loading is why the fast factor that bought G2++ its fit to short-expiry vols barely touches long rates, the decorrelation of L5.3.10: Two-factor models.
Move the two factors of G2++
Module 5.3's two-factor fit with a constant shift φ = 3%. The fast factor x halves in about a month; the slow factor y in about 30 years.
Both factors at zeroAt the state you set
10y yield2.903%
10y change0.00bp
= loading on x × x0.0119 × 0
+ loading on y × y0.8932 × 0
6m yield change0.00bp
6m loadings (x, y)0.234, 0.994
Affine yields are what make the rest of the module work. A curve observed on any day is the intercepts plus the loadings times that day's factors, plus some error: a linear equation in the factors. That is why principal components can be read as factors (L5.4.03: Multi-factor affine models), why Nelson-Siegel's curve has the same shape (L5.4.05: Arbitrage-free Nelson-Siegel) and why the Kalman filter can estimate the factors month by month (L5.4.06: Estimation with the Kalman filter). The same ODEs give the instantaneous forward rate, f(τ) = −A′(τ) + B′(τ)ᵀx, with no differencing.
Solving the Riccati equations
Vasicek, CIR and G2++ have closed-form A and B. Many affine models do not, for example several square-root factors that feed into each other. Then the ODEs are solved numerically. The standard tool is the classical Runge-Kutta methodClassical Runge-Kutta (RK4): a step of an ODE built from four slopes, at the start, twice at the middle and at the end, averaged with weights 1, 2, 2, 1. Its error falls like the step to the fourth power., RK4: to step from τ to τ + h, take the slope at the start (k₁), at the middle twice (k₂ from a half step along k₁, k₃ from a half step along k₂) and at the end (k₄ from a full step along k₃), and move by h(k₁ + 2k₂ + 2k₃ + k₄)/6. Euler's method of M-B06: Differential equations uses k₁ alone and its error falls like h; RK4's falls like h⁴.
Vasicek fit, RK4 at 100 steps a year against Module 5.3's closed forms (A is ln A in the notation of L5.3.02: The Vasicek model). The largest difference at the ten table maturities is 1.4 × 10⁻¹⁴: rounding.
Maturity
B(τ), RK4
B(τ), closed form
A(τ), RK4
A(τ), closed form
1y
0.973064
0.973064
−0.001536
−0.001536
5y
4.372853
4.372853
−0.034691
−0.034691
10y
7.696638
7.696638
−0.123353
−0.123353
25y
13.602946
13.602946
−0.570464
−0.570464
CIR's equation is the harder test, because of its B² term. The worst error in ln P over the ten table maturities to 25 years:
CIR fit to the curve (r₀ = SONIA). A fourth-order method should cut the error by about 16 each time the step halves.
RK4 steps a year
Worst |ln P error|
Fall when the step halves
1
3.0 × 10⁻⁸
2
2.0 × 10⁻⁹
× 1/14.8
4
1.2 × 10⁻¹⁰
× 1/16.1
12
1.5 × 10⁻¹²
100
below 10⁻¹⁵
At one step a year the error is already 3.0 × 10⁻⁸ in ln P, a tiny fraction of a basis point of yield. At 12 steps it is 1.5 × 10⁻¹²; at 100, the default here, it is below 10⁻¹⁵, the limit of the computer's arithmetic. Two Riccati equations that a closed form can check are the reason to trust the solver on the ones it cannot.
The formal version
Affine bond prices and the Riccati ODEs
Under the pricing measure ℚ, with an N-dimensional state x, a Brownian motion W, τ = T − t (Duffie and Kan 1996; Brigo and Mercurio 2006, §3.2.4):
r=δ0+δ1⊤x,dx=K(θ−x)dt+ΣS(x)dW,S(x)=diag(αi+βi⊤x)P(t,T)=EQ[e−∫tTrdsx(t)=x]=exp(A(τ)−B(τ)⊤x)B′(τ)=δ1−K⊤B−21i=1∑N[(Σ⊤B)i]2βi,B(0)=0A′(τ)=−(Kθ)⊤B+21i=1∑N[(Σ⊤B)i]2αi−δ0,A(0)=0y(τ)=−τA(τ)+(τB(τ))⊤x,f(τ)=−A′(τ)+B′(τ)⊤xRK4 for z′=g(z):k1=g(zn),k2=g(zn+2hk1),k3=g(zn+2hk2),k4=g(zn+hk3)RK4 for z′=g(z):zn+1=zn+6h(k1+2k2+2k3+k4),global error=O(h4)
K (N × N) is the mean-reversion matrix and θ the long-run mean under ℚ; Σ (N × N) scales the shocks; each shock i has variance αᵢ + βᵢᵀx, which must stay non-negative (the parameters must be admissibleAdmissible: a set of parameters for which the model exists, for example a square-root factor that cannot become negative. L5.4.03: Multi-factor affine models gives the conditions.). δ₀ and δ₁ make the short rate. (ΣᵀB)ᵢ is the i-th entry of the vector ΣᵀB. y is the zero yield and f the instantaneous forward rate, both continuously compounded. Duffie and Kan showed that yields are affine in the factors if and essentially only if the drift and variance are; the “only if” needs a mild condition on the model. For RK4, z stacks A and B and g is the right-hand side of the two ODEs: the classical fourth-order Runge-Kutta scheme (Weisstein, MathWorld).
Try it
Solve the two one-factor models yourself. The tool starts at the CIR fit with one RK4 step a year; the dots are RK4, the line the closed form. Read the table as you move from 1 to 2 to 4 steps, then make the B² term stronger by raising σ.
Try itSolve the Riccati equations by RK4
Model
RK4 steps a year
Closed formRK4, 1 step a yearWithout the B² term (Vasicek's B)
B(10), RK47.801443
B(10), closed form7.801444
10y yield at r₀, RK44.1020%
10y yield, closed form4.1020%
Worst |ln P error| to 25y3.0 × 10⁻⁸
Worst yield error1.7 × 10⁻⁵bp
Feller ratio 2κθ/σ²2.58
RK4 against the closed form for these parameters: worst |ln P error| over 6 months to 25 years
Steps a year
Worst error
Fall when the step halves
1
3.0 × 10⁻⁸
2
2.0 × 10⁻⁹
× 1/14.8
4
1.2 × 10⁻¹⁰
× 1/16.1
12
1.5 × 10⁻¹²
100
rounding only
In CIR the B² term bends B below Vasicek's curve (dashed). Read the table: each halving of the step cuts the worst error by about 16 = 2⁴, the mark of a fourth-order method. Raise σ to make the B² term stronger and the error at one step a year grows with it: about 25 times the fit's at σ = 0.15, a hundredfold only from about 0.24, and some 200 times at the top of the slider, 0.30. At 100 steps a year it stays below 10⁻¹³, rounding level. Switch to Vasicek: its B equation is linear, yet RK4 still replaces e^(−κh) by the first terms of its series, and A's equation carries ½σ²B², so RK4 is not exact there either.
Worked example
One RK4 step for CIR's 1-year bond
The CIR fit at 31 December 2025, one step of a year
A numerical solver is part of a model's implementation, and supervisors expect it to be checked. The Prudential Regulation Authority's model risk principles for banks, SS1/23 (effective 17 May 2024), ask firms to compare a model's output “with the outcomes of alternative theories or approaches and benchmarks” where possible (sub-principle 3.1(b), numbered the same in the May 2023 text and the April 2026 update) and to verify that models are “implemented as intended” (process verification, 4.3(a)). Testing an RK4 solver against the closed forms it should reproduce, before trusting it on models with none, is that check in miniature. Model validation as a discipline is M6.7: Model risk, validation and machine learning; model risk in rate models comes back in L5.5.10: Model risk in rate models.
Spark Atoms
✦Spark AtomThe count who stayed at home+
Count Jacopo Riccati (1676–1754), born in Venice, probably began studying his equation around 1715; its first written record seems to be a letter of 1720 to Giovanni Rizzetti. He declined the presidency of the St Petersburg Academy of Sciences, offered by Peter the Great, and a chair at Padua. At home he served nine years as mayor of Castelfranco Veneto, between 1698 and 1729. Three centuries later his equation prices every CIR bond.
✦Spark AtomIf and essentially only if+
Duffie and Kan's 1996 paper started from the other end. They wanted a model in which a few benchmark yields are the factors and every other yield is a fixed combination of them. They proved that this happens if and essentially only if the factors' drift and variance are affine, and that bond prices then solve Riccati equations. The affine family was not chosen for convenience: it is exactly the family in which yields are linear in the factors.
Key takeaways
A model is affine when its short rate, its drift and its shock variance are each a constant plus a linear term in the state.
Then every bond price is exp(A(τ) − B(τ)ᵀx): the pricing PDE splits into a constant part and a part linear in x, and each must vanish.
B solves a Riccati ODE, quadratic in B through the variance; A follows as an integral. Vasicek's B equation is linear, CIR's is the Riccati equation of M-B06: Differential equations.
Yields are affine in the factors, with loadings B(τ)/τ that do not depend on the state: G2++'s 10-year yield moves 0.8932bp per bp of the slow factor at every state.
RK4 solves the ODEs where no closed form exists; on CIR its error falls about 16-fold per halving of the step, to below 10⁻¹⁵ at 100 steps a year.
Reaction
Check what stuck
Question 1 · objective 3
In the G2++ fit the 10-year zero yield loads 0.8932 on the slow factor y and 0.0119 on the fast factor x. If y rises by 25bp and x does not move, by how many basis points does the 10-year yield rise? (Two decimals.)
bp
Question 2 · objective 3
In the Vasicek fit, A(10) = −0.12335 and B(10) = 7.6966, and today's short rate is r₀ = 3.7257%. What is the 10-year zero yield, −A/τ + (B/τ)r₀, in %? (Three decimals.)
%
Question 3 · objective 2
Putting P = exp(A(τ) − B(τ)ᵀx) into the pricing PDE leaves a constant plus a term that multiplies x. Why must each be zero on its own?
Question 4 · objective 1
Which of these short-rate models is not affine?
Question 5 · objective 4
RK4 is a fourth-order method. When you halve its step, the error at a fixed maturity falls by roughly what factor?
Glossary
State vector
State vector: the few numbers x = (x₁, …, x_N) that, with the model's parameters, fix every bond price today. In Vasicek and CIR it is the short rate; in G2++ the two factors.
Affine
Affine: a constant plus a linear term, a + bᵀx. A model is affine when the short rate, the drift and the variance of the state are all affine in the state.
Exponential-affine
Exponential-affine: of the form exp(A − Bᵀx). Bond prices in an affine model have this form, so log prices and yields are affine in the state.
Riccati equation
Riccati equation: a first-order ODE that is quadratic in the unknown, dy/dτ = q₀ + q₁y + q₂y². In affine models B solves one; its square comes from the variance term.
Yield loading
Yield loading: B(τ)/τ, how many basis points the τ-year yield moves per basis point of a factor. In an affine model it does not depend on the state.
Runge-Kutta (RK4)
Classical Runge-Kutta (RK4): a step of an ODE built from four slopes, at the start, twice at the middle and at the end, averaged with weights 1, 2, 2, 1. Its error falls like the step to the fourth power.
Admissible
Admissible: a set of parameters for which the model exists, for example a square-root factor that cannot become negative. L5.4.03: Multi-factor affine models gives the conditions.