# Affine term structure model

An affine term structure model is a financial model that relates zero-coupon bond prices (i.e. the discount curve) to a spot rate model. It is particularly useful for deriving the yield curve – the process of determining spot rate model inputs from observable bond market data. The affine class of term structure models implies the convenient form that log bond prices are linear functions of the spot rate (and potentially additional state variables).

## Background

Start with a stochastic short rate model $r(t)$ with dynamics:
    $dr(t)=\mu (t,r(t))\,dt+\sigma (t,r(t))\,dW(t)$
and a risk-free zero-coupon bond maturing at time $T$ with price $P(t,T)$ at time $t$. The price of a zero-coupon bond is given by:$P(t,T)=\mathbb {E} ^{\mathbb {Q} }\left\{\exp \left[-\int _{t}^{T}r(t')dt'\right]\right\}$where $T=t+\tau$, with $\tau$ being is the bond's maturity. The expectation is taken with respect to the risk-neutral probability measure $\mathbb {Q}$. If the bond's price has the form:
    $P(t,T)=e^{A(t,T)-rB(t,T)}$
where $A$ and $B$ are deterministic functions, then the short rate model is said to have an affine term structure. The yield of a bond with maturity $\tau$, denoted by $y(t,\tau )$, is given by:$y(t,\tau )=-{1 \over {\tau }}\log P(t,\tau )$

### Feynman-Kac formula

For the moment, we have not yet figured out how to explicitly compute the bond's price; however, the bond price's definition implies a link to the Feynman-Kac formula, which suggests that the bond's price may be explicitly modeled by a partial differential equation. Assuming that the bond price is a function of $x\in \mathbb {R} ^{n}$ latent factors leads to the PDE:$-{\partial P \over {\partial \tau }}+\sum _{i=1}^{n}\mu _{i}{\partial P \over {\partial x_{i}}}+{1 \over {2}}\sum _{i,j=1}^{n}\Omega _{ij}{\partial ^{2}P \over {\partial x_{i}\partial x_{j}}}-rP=0,\quad P(0,x)=1$where $\Omega$ is the covariance matrix of the latent factors where the latent factors are driven by an Ito stochastic differential equation in the risk-neutral measure:$dx=\mu ^{\mathbb {Q} }dt+\Sigma dW^{\mathbb {Q} },\quad \Omega =\Sigma \Sigma ^{T}$Assume a solution for the bond price of the form:$P(\tau ,x)=\exp \left[A(\tau )+x^{T}B(\tau )\right],\quad A(0)=B_{i}(0)=0$The derivatives of the bond price with respect to maturity and each latent factor are:${\begin{aligned}{\partial P \over {\partial \tau }}&=\left[A'(\tau )+x^{T}B'(\tau )\right]P\\{\partial P \over {\partial x_{i}}}&=B_{i}(\tau )P\\{\partial ^{2}P \over {\partial x_{i}\partial x_{j}}}&=B_{i}(\tau )B_{j}(\tau )P\\\end{aligned}}$With these derivatives, the PDE may be reduced to a series of ordinary differential equations:$-\left[A'(\tau )+x^{T}B'(\tau )\right]+\sum _{i=1}^{n}\mu _{i}B_{i}(\tau )+{1 \over {2}}\sum _{i,j=1}^{n}\Omega _{ij}B_{i}(\tau )B_{j}(\tau )-r=0,\quad A(0)=B_{i}(0)=0$To compute a closed-form solution requires additional specifications.

## Existence

Using Ito's formula we can determine the constraints on $\mu$ and $\sigma$ which will result in an affine term structure. Assuming the bond has an affine term structure and $P$ satisfies the term structure equation, we get:
    $A_{t}(t,T)-(1+B_{t}(t,T))r-\mu (t,r)B(t,T)+{\frac {1}{2}}\sigma ^{2}(t,r)B^{2}(t,T)=0$
The boundary value
    $P(T,T)=1$
implies
    ${\begin{aligned}A(T,T)&=0\\B(T,T)&=0\end{aligned}}$
Next, assume that $\mu$ and $\sigma ^{2}$ are affine in $r$:
    ${\begin{aligned}\mu (t,r)&=\alpha (t)r+\beta (t)\\\sigma (t,r)&={\sqrt {\gamma (t)r+\delta (t)}}\end{aligned}}$
The differential equation then becomes
    $A_{t}(t,T)-\beta (t)B(t,T)+{\frac {1}{2}}\delta (t)B^{2}(t,T)-\left[1+B_{t}(t,T)+\alpha (t)B(t,T)-{\frac {1}{2}}\gamma (t)B^{2}(t,T)\right]r=0$
Because this formula must hold for all $r$, $t$, $T$, the coefficient of $r$ must equal zero.
    $1+B_{t}(t,T)+\alpha (t)B(t,T)-{\frac {1}{2}}\gamma (t)B^{2}(t,T)=0$
Then the other term must vanish as well.
    $A_{t}(t,T)-\beta (t)B(t,T)+{\frac {1}{2}}\delta (t)B^{2}(t,T)=0$
Then, assuming $\mu$ and $\sigma ^{2}$ are affine in $r$, the model has an affine term structure where $A$ and $B$ satisfy the system of equations:
    ${\begin{aligned}1+B_{t}(t,T)+\alpha (t)B(t,T)-{\frac {1}{2}}\gamma (t)B^{2}(t,T)&=0\\B(T,T)&=0\\A_{t}(t,T)-\beta (t)B(t,T)+{\frac {1}{2}}\delta (t)B^{2}(t,T)&=0\\A(T,T)&=0\end{aligned}}$

## Models with ATS
### Vasicek

The Vasicek model $dr=(b-ar)\,dt+\sigma \,dW$ has an affine term structure where
    ${\begin{aligned}p(t,T)&=e^{A(t,T)-B(t,T)r(t)}\\B(t,T)&={\frac {1}{a}}\left(1-e^{-a(T-t)}\right)\\A(t,T)&={\frac {(B(t,T)-T+t)(ab-{\frac {1}{2}}\sigma ^{2})}{a^{2}}}-{\frac {\sigma ^{2}B^{2}(t,T)}{4a}}\end{aligned}}$

## Arbitrage-Free Nelson-Siegel

One approach to affine term structure modeling is to enforce an arbitrage-free condition on the proposed model. In a series of papers, a proposed dynamic yield curve model was developed using an arbitrage-free version of the famous Nelson-Siegel model, which the authors label AFNS. To derive the AFNS model, the authors make several assumptions:
* There are three latent factors corresponding to the level, slope, and curvature of the yield curve
* The latent factors evolve according to multivariate Ornstein-Uhlenbeck processes. The particular specifications differ based on the measure being used:
** $dx=K^{\mathbb {P} }(\theta -x)dt+\Sigma dW^{\mathbb {P} }$ (Real-world measure $\mathbb {P}$)
** $dx=-K^{\mathbb {Q} }xdt+\Sigma dW^{\mathbb {Q} }$ (Risk-neutral measure $\mathbb {Q}$)
* The volatility matrix $\Sigma$ is diagonal
* The short rate is a function of the level and slope ($r=x_{1}+x_{2}$)
From the assumed model of the zero-coupon bond price:$P(\tau ,x)=\exp \left[A(\tau )+x^{T}B(\tau )\right]$The yield at maturity $\tau$ is given by:$y(\tau )=-{A(\tau ) \over {\tau }}-{x^{T}B(\tau ) \over {\tau }}$And based on the listed assumptions, the set of ODEs that must be solved for a closed-form solution is given by:$-\left[A'(\tau )+B'(\tau )^{T}x\right]-B(\tau )^{T}K^{\mathbb {Q} }x+{1 \over {2}}B(\tau )^{T}\Omega B(\tau )-\rho ^{T}x=0,\quad A(0)=B_{i}(0)=0$where $\rho ={\begin{pmatrix}1&1&0\end{pmatrix}}^{T}$ and $\Omega$ is a diagonal matrix with entries $\Omega _{ii}=\sigma _{i}^{2}$. Matching coefficients, we have the set of equations:${\begin{aligned}-B'(\tau )&=\left(K^{\mathbb {Q} }\right)^{T}B(\tau )+\rho ,\quad B_{i}(0)=0\\A'(\tau )&={1 \over {2}}B(\tau )^{T}\Omega B(\tau ),\quad A(0)=0\end{aligned}}$To find a tractable solution, the authors propose that $K^{\mathbb {Q} }$ take the form:$K^{\mathbb {Q} }={\begin{pmatrix}0&0&0\\0&\lambda &-\lambda \\0&0&\lambda \end{pmatrix}}$Solving the set of coupled ODEs for the vector $B(\tau )$, and letting ${\mathcal {B}}(\tau )=-{1 \over {\tau }}B(\tau )$, we find that:${\mathcal {B}}(\tau )={\begin{pmatrix}1&{1-e^{-\lambda \tau } \over {\lambda \tau }}&{1-e^{-\lambda \tau } \over {\lambda \tau }}-e^{-\lambda \tau }\end{pmatrix}}^{T}$Then $x^{T}{\mathcal {B}}(\tau )$ reproduces the standard Nelson-Siegel yield curve model. The solution for the yield adjustment factor ${\mathcal {A}}(\tau )=-{1 \over {\tau }}A(\tau )$ is more complicated, found in Appendix B of the 2007 paper, but is necessary to enforce the arbitrage-free condition.

### Average expected short rate

One quantity of interest that may be derived from the AFNS model is the average expected short rate (AESR), which is defined as:${\text{AESR}}\equiv {1 \over {\tau }}\int _{t}^{t+\tau }\mathbb {E} _{t}(r_{s})ds=y(\tau )-{\text{TP}}(\tau )$where $\mathbb {E} _{t}(r_{s})$ is the conditional expectation of the short rate and ${\text{TP}}(\tau )$ is the term premium associated with a bond of maturity $\tau$. To find the AESR, recall that the dynamics of the latent factors under the real-world measure $\mathbb {P}$ are:$dx=K^{\mathbb {P} }(\theta -x)dt+\Sigma dW^{\mathbb {P} }$The general solution of the multivariate Ornstein-Uhlenbeck process is:$x_{t}=\theta +e^{-K^{\mathbb {P} }t}(x_{0}-\theta )+\int _{0}^{t}e^{-K^{\mathbb {P} }(t-t')}\Sigma dW^{\mathbb {P} }$Note that $e^{-K^{\mathbb {P} }t}$ is the matrix exponential. From this solution, it is possible to explicitly compute the conditional expectation of the factors at time $t+\tau$ as:$\mathbb {E} _{t}(x_{t+\tau })=\theta +e^{-K^{\mathbb {P} }\tau }(x_{t}-\theta )$Noting that $r_{t}=\rho ^{T}x_{t}$, the general solution for the AESR may be found analytically:${1 \over {\tau }}\int _{t}^{t+\tau }\mathbb {E} _{t}(r_{s})ds=\rho ^{T}\left[\theta +{1 \over {\tau }}\left(K^{\mathbb {P} }\right)^{-1}\left(I-e^{-K^{\mathbb {P} }\tau }\right)(x_{t}-\theta )\right]$