Skip to content
All library documents

Implicit Differentiation for Calibration and Market-Rate Sensitivities

Article Quant Q&A · Author: loyd.f

Summary

The document explains how the implicit function theorem can translate changes in market quotes into changes in calibrated parameters. For a Nelson-Siegel-Svensson curve fitted by minimizing squared rate errors, it starts from the optimizer’s first-order condition: the gradient of the objective is zero at the solution. Differentiating that condition yields parameter sensitivities from the inverse derivative of the gradient and its derivative with respect to observed rates. The required quantities are evaluated at the calibrated parameters.

It distinguishes this optimization setting from exact bootstrapping, where calibrated parameters make instrument pricing errors zero. In that case, sensitivities follow from the Jacobian of pricing errors with respect to parameters and quotes; an overdetermined system requires a pseudoinverse. The answer connects curve sensitivities to portfolio instrument risk. It gives a derivation and dimension guidance, but no numerical example, and its displayed formulas should be checked carefully when implementing the method.

Key ideas

  • For least-squares calibration, differentiate the zero-gradient condition to relate quote changes to parameter changes.
  • The sensitivity calculation uses derivatives of the objective’s first-order condition, evaluated at the fitted parameters.
  • Exact bootstrapping instead differentiates instrument pricing errors with respect to curve parameters and market quotes.
  • When the bootstrap system has more equations than parameters, a pseudoinverse can be used.
  • Portfolio sensitivities can be built by combining instrument risk to curve parameters with curve-parameter sensitivities to quotes.

Tags

Full text
# Implicit function theorem and sensitivities to market risk for Nelson-Siegel-Svensson model


# Implicit function theorem and sensitivities to market risk for Nelson-Siegel-Svensson model












I’m calibrating the Nelson-Siegel-Svensson model to market rates and I’m trying to compute the sensitivities of the NSS parameters to those said rates:

$$r\left(T\right)=\beta_{0}+\beta_{1}{\frac{\left[{1-\exp\left({-T/\lambda}\right)}\right]}{T/\lambda}}+\beta_{2}{\left({\frac{\left[{1-\exp\left({-T/\lambda}\right)}\right]}{T/\lambda}}-\exp\left({-T/\lambda}\right)\right)}+\beta_{3}{\left({\frac{\left[{1-\exp\left({-T/\kappa}\right)}\right]}{T/\kappa}}-\exp\left({-T/\kappa}\right)\right)}.$$

I'm calibrating the model using Levenberg-Marquardt algorithm.

Let's call the parameters $b=\{\beta_0^*,\beta_1^*,\beta_2^*,\beta_3^*,\lambda^*,\kappa^*\}\in\mathbb{R}^{n=6}$, such that, for $m$ observed rates in the market for $m$ maturities ($m>n$), we have:

$$\forall i = 1,...,m, \, f_{i}(r_{i},T_{i};b)=r(T_i;b) - r_i=0.$$

What I want to compute is the sensitivities of $b$ w.r.t ${r_1,...,r_m}$:

$$\frac{\partial b}{\partial r}={\begin{pmatrix}{\dfrac {\partial \beta_0^*}{\partial r_{1}}}&\cdots &{\dfrac {\partial \beta_0^*}{\partial r_{m}}}\\\vdots &\ddots &\vdots \\{\dfrac {\partial \kappa^*}{\partial r_{1}}}&\cdots &{\dfrac {\partial \kappa^*}{\partial r_{m}}}\end{pmatrix}}\in\mathbb{R}^{n\times m}.$$

I found this paper which is the closest to possibly have the answer to my problem:

- From model to market risks: The Implicit Function Theorem (IFT) demystified

But I'm still missing some things. It says the following (page. 3): using the implicit function theorem, we have

$$\underbrace{\frac{\partial b}{\partial r}}_{n\times m}=\underbrace{\left(\frac{\partial I}{\partial b}\right)^{-1}}_{m\times i}\left[\underbrace{\frac{\partial I}{\partial r}}_{i\times n}-\underbrace{\frac{\partial I}{\partial c}}_{i\times p}\underbrace{\frac{\partial c}{\partial r}}_{p\times n}\right]$$

with:

- $I$ being a "set of $i$ calibrated instruments" (?)

- $c$ being a "set of $p$ additional parameters" (?)

That's where I fail to go further. In my specific case, what are my set $I$ and $c$?

## Answer by Kermittfrog (score 4, accepted)

https://quant.stackexchange.com/a/79866

To my understanding, there exist two ways to invoke the IFT in quantitative finance applications in a calibration / bootstrapping context.

- When minimizing some error function during bootstrapping.

- When bootstrapping a set of parameters (e.g. a zero curve) so that all reference instruments are priced exactly to par (e.g. zero PV for a swap),

### IFT in optimization problems

I understand that you tackle the first question, where you minimize a scalar error function. To simplify notation, collect all the parameters into the $K \times 1$ vector $\theta$ and write

$$ \min_{\theta} f(\theta,y) = \sum_i\left(y(T_i)-r(T_i,\theta)\right)^2 $$

Once the minimization of $f$ has been performed, we have obtained some optimal $\theta^*$. From optimization theory, we know that the following optimization condition must hold at the optimum:

$$ g\equiv\left.\frac{\mathrm{d}f(\theta,y)}{\mathrm{d}\theta}\right|_{\theta=\theta^*}=0 $$

This can be used as the starting point for finding the relationship between changes in input data and the calibrated parameters. In layman's terms: When the inputs $y$ change (by a little bit), the optimization routine will still induce that $g=0$ at the optimum, i.e. it stays at zero:

$$ \begin{align} \frac{\mathrm{d}g}{\mathrm{d}y}&= \frac{\mathrm{d}g}{\mathrm{d}\theta}\frac{\mathrm{d}\theta}{\mathrm{d}y}+\frac{\mathrm{d}g}{\mathrm{d}y}=0 \\ \Rightarrow \frac{\mathrm{d}\theta}{\mathrm{d}y}&=-\left(\frac{\mathrm{d}g}{\mathrm{d}\theta}\right)^{-1}\frac{\mathrm{d}g}{\mathrm{d}y} \end{align} $$

Hence, given our scalar optimization problem $f$, the relationship between (small) changes to the inputs and the calibrated parameters are found using derivatives of the first-order-condition.

Let's try this for the NSS example you provide, assuming we want to minimize the squared errors. Further, let us introduce simplifying notation:

- $g_i$ is the the $k\times 1$ gradient of the NSS model at $T_i$, and

- $H_i$ is the $k\times k$ matrix of second derivatives of the NSS model at $T_i$.

Then:

$$ \begin{align} f&=\sum_i(y_i-r(T_i))^2\\ g&\equiv \frac{\mathrm{d}f}{\mathrm{d}\theta}=-2\sum_i(y_i-r(T_i))g_i\}\stackrel{!}{=}0 \end{align} $$ Note that I have used the "$\stackrel{!}{=}0$" rather sloppily to indicate that, at $\theta=\theta^*$, the gradient of the problem must be zero, else we could improve the optimization further. Now we repeat the tools from above, i.e. invoke the notion that, $\mathrm{d}g$ must be zero when changing to another $y$. To this end, we need

$$ \frac{\mathrm{d}g}{\mathrm{d}y}=-2\begin{pmatrix} \frac{\mathrm{d}r(T_1)}{\mathrm{d}\theta} & \frac{\mathrm{d}r(T_2)}{\mathrm{d}\theta} & \ldots & \frac{\mathrm{d}r(T_n)}{\mathrm{d}\theta} \end{pmatrix}\equiv J $$ which is of dimension $k \times n$ and of course $$ \frac{\mathrm{d}g}{\mathrm{d}\theta}=-2\sum_iy_iH_i-g_ig_i^T- r(T_i)H_i\equiv G $$ which is of dimension $k \times k$

Finally, we have

$$ \frac{\mathrm{d}\theta}{\mathrm{d}y}=-G^{-1}J $$ which is of dimension $k \times n$ and to be calculated at $\theta=\theta^*$.

NB: Most optimizers will offer both Hessian and Jacobian of the model as a by-product, AFAIK.

### IFT in standard bootstrapping

A common bootstrapping problem is to find a set of $K\leq N$ parameters $\theta$ (e.g. zero rate nodes in a interest rate curve) so that we can calibrate $N$ reference instruments to their respective quotes, stored in vector $Q$, dimension $N \times 1$.

Let $f$ be a $N\times 1$ vector of reference instruments that (conveniently) have to be priced at par (i.e. zero). Assume that $\theta^*$ has been calibrated such. Any update of $Q$ shall result in an update of $\theta$ such that, again, $f=0$. Then

$$ \frac{\mathrm{d}f}{\mathrm{d}y}=\frac{\mathrm{d}f}{\mathrm{d}\theta}\frac{\mathrm{d}\theta}{\mathrm{d}y}+\frac{\mathrm{d}f}{\mathrm{d}y}\stackrel{!}{=}0 $$

and again

$$ \frac{\mathrm{d}\theta}{\mathrm{d}y}=-\left(\frac{\mathrm{d}f}{\mathrm{d}\theta}\right)^{-1}\frac{\mathrm{d}f}{\mathrm{d}y} $$

If $K<N$, we have to come up with a pseudeo inverse, i.e.

$$ \frac{\mathrm{d}\theta}{\mathrm{d}y}=-\left[\left(\frac{\mathrm{d}f}{\mathrm{d}\theta}\right)^T\frac{\mathrm{d}f}{\mathrm{d}\theta}\right]^{-1}\left(\frac{\mathrm{d}f}{\mathrm{d}\theta}\right)^T\frac{\mathrm{d}f}{\mathrm{d}y} $$

A typical application, then, is to find sensitivites of some instrument $h$ in our portfolio with respect to market observed swap rates. Let $ \theta$ be parameters of the (zero-root) bootstrapped curve, commonly zero rates. Then:

$$ \frac{\mathrm{d}h}{\mathrm{d}q}=\frac{\mathrm{d}h}{\mathrm{d}\theta}\frac{\mathrm{d}\theta}{\mathrm{d}r}=-\frac{\mathrm{d}h}{\mathrm{d}\theta}\left(\frac{\mathrm{d}f}{\mathrm{d}\theta}\right)^{-1}\frac{\mathrm{d}f}{\mathrm{d}y} $$

where we use the "zero sensitivities" of our instrument and the (precomputed) sensitivities of the zero rates w.r.t. the quotes.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.