Category Archives: Uncategorized

Sensitivity of an annuity to yield curve extrapolation parameters

Today, at the JIRF (Journée Interuniversitaire de Recherche en Finance @ IAE Gustave Eiffel), I talked about the sensitivity of an annuity to Solvency II yield curve extrapolation parameters.

The slides can be found here (in English, despite the title):

You can play around with an interactive (RStudio’s Shiny) web application, by clicking on the following link (I’d suggest to read the slides first, to fully understand what it does 🙂 ):

However, the app is “alive” for 25 hours per month (i picked the free tier on the server). For a permanent access to the app, you can also type the following commands in R:

# Loading Shiny package


# Runs the app in your browser; execs code from my Gist 


Capture d’écran 2015-05-22 à 00.18.59

Leave a comment

Filed under Uncategorized

Announcing ESGtoolkit v0.1

I’m pleased to announce the release on CRAN repositories, of our new R package : ESGtoolkit.

It’s a set of tools for Monte Carlo simulation of various models, involved in the construction of an Economic Scenario Generator (ESG),  such as : equilibrium and no-arbitrage short rates models, equity models such as Black-Scholes, Merton, Heston and Bates (also known as Heston-Merton or Stochastic Volatility Jump diffusion), etc. The core loops of the simulations are made in C++. 


In addition, a highly flexible correlation or dependence structure can be added between the simulations of different risk factors, with the use of vine copulas.

This note (the package’s vignette) will give you more insight on the features of this new package.

Comments and suggestions (constructive ? :)) are appreciated and highly valued. 



Leave a comment

Filed under Uncategorized

R Style guide


Here is a style guide for R, designed in collaboration with the entire R user community at Google :

I don’t always use all these rules, I can forget some of them sometimes. But we all need to have them in mind, in order to keep our code shareable. In the spirit of R.

A package that helps in automatically formatting R scripts, is formatR. The package’s wiki on GitHub contains good examples of use of this tool.


Leave a comment

Filed under Uncategorized

R package ‘ycinterextra’ is now available on CRAN

ycinterextra, an R package for yield curve or zero-coupon prices interpolation and extrapolation is now available on CRAN.

The yield curve models currently available are Nelson-Siegel, Svensson, Smith-Wilson, and Hermite cubic splines. The output can be either rates or prices, no matter the input data type (prices or rates).

Here is a simple example of use of this package, featuring Svensson and Smith-Wilson interpolation.


# Yield to maturities
txZC <- c(0.01422, 0.01309, 0.0138, 0.01549, 0.01747, 
0.0194, 0.02104, 0.02236, 0.02348, 0.02446, 0.02535, 
0.02614, 0.02679, 0.02727, 0.0276, 0.02779, 0.02787, 
0.02786, 0.02776, 0.02762, 0.02745, 0.02727, 0.02707,
0.02686, 0.02663, 0.0264, 0.02618, 0.02597, 0.02578, 

# Observed maturities
u <- 1:30

# Output maturities
t <- seq(from = 1, to = 30, by = 0.5)

# Svensson interpolation
ycSV <- ycinter(yM = txZC, matsin = u, matsout = t, 
method = "SV", typeres = "rates")

# Smith-Wilson interpolation
ycSW <- ycinter(yM = txZC, matsin = u, matsout = t, 
method = "SW", typeres = "rates")

The residuals for each model can be obtained with :


## Time Series:
## Start = 1 
## End = 30 
## Frequency = 1 
## [1]  1.485e-04 -2.080e-04 -2.107e-04  7.469e-06  2.051e-04  3.095e-04
## [7]  2.317e-04  1.890e-05 -1.773e-04 -2.924e-04 -2.877e-04 -1.920e-04
## [13] -6.796e-05  3.148e-05  1.043e-04  1.402e-04  1.514e-04  1.420e-04
## [19]  9.859e-05  5.967e-05  2.558e-05  8.246e-06 -9.032e-06 -2.176e-05
## [25] -4.445e-05 -6.077e-05 -6.366e-05 -5.550e-05 -2.817e-05  3.688e-05


## Time Series:
## Start = 1 
## End = 30 
## Frequency = 1 
## [1] 4.007e-13 3.915e-13 3.963e-13 3.983e-13 3.985e-13 4.134e-13 4.232e-13
## [8] 4.288e-13 4.608e-13 4.423e-13 4.430e-13 4.428e-13 4.366e-13 4.378e-13
## [15] 4.290e-13 4.241e-13 4.150e-13 4.084e-13 4.003e-13 3.925e-13 3.859e-13
## [22] 3.726e-13 3.606e-13 3.491e-13 3.368e-13 3.249e-13 3.128e-13 3.011e-13
## [29] 2.893e-13 2.784e-13

Some diagnostic plots can also be drawn with the following command :


Diagnostic plot from ycinterextra


Filed under Uncategorized

Yield curve interpolation and extrapolation

R package ycinterextra achieves yield curve or zero-coupon bonds prices interpolation/extrapolation.

The methods currently available are Nelson-Siegel, Svensson, Smith-Wilson for both interpolation and extrapolation, and Hermite cubic spline for extrapolation.



Leave a comment

Filed under Uncategorized

A demo of R package ESG v0.1

The package ESG is a simple Economic Scenario Generator designed with R, for the purpose of actuarial valuations. The first version v0.1 can be found on CRAN repository :

An example of use of  this package, featuring short rate and equity projection, as well as a Best Estimate liability valuation, can be found here.

The files that have been used for this example can be found here, at the bottom of the page.

Future versions will include Martingale tests, inflation, a more flexible correlation structure…

Feedbacks are welcome !

Leave a comment

Filed under Uncategorized

mcGlobaloptim: Global optimization using Monte Carlo and Quasi Monte Carlo simulation

For the purpose of Market Consistent actuarial valuation, we need to calibrate our models to market data. Traditional optimization methods based only on gradient (Newton, quasi-Newton…) fail, or provide volatile results. Indeed, they search for a solution in a local neighborhood, while objective functions might exhibit multiple local minima. The R package mcGlobaloptim achieves global optimization, combining Monte Carlo and Quasi-Monte Carlo simulation with local searches. The local searches can be speeded-up by the use of your computer’s (multiple) cores.

Currently, the function multiStartoptim generates pseudo-random and quasi-random numbers within the search domain specified by its bounds. Local searches are then performed by a user-selected method, either on the whole set of numbers generated as starting points, or only on the points lying under the objective function’s median. When (and only when) a high number of local searches are to be performed, parallel computation can be used to speed-up the search

Leave a comment

October 28, 2013 · 6:34 pm