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.

require(ycinterextra)

# 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, 
0.02563)

# 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 :

residuals(ycSV)

## 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

residuals(ycSW)

## 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 :

ycplot(ycSV)

Diagnostic plot from ycinterextra
Advertisements

3 Comments

Filed under Uncategorized

3 responses to “R package ‘ycinterextra’ is now available on CRAN

  1. Pingback: Solvency II yield curve ‘fits exactly’. Too tightly to explain ? | Thierry Moudiki's blog

  2. does this assume that we are using par bonds?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s