O'Reilly logo

Introduction to R for Quantitative Finance by Zsolt Tulassay, Dr. Kata Váradi, Péter Csóka, Michael Puhle, Márton Michaletzky, Gergely Daróczi, Dr. Edina Berlinger, Daniel Havran, Agnes Vidovics-Dancs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applied R functions

Although we have already used some functions from the termstrc package in the previous example to demonstrate how one can determine the ideal number of knot points and also specify those, this process can be done in an easier manner with some further R functions, as shown in the following command lines:

> x <- estim_cs(govbonds, 'GERMANY')
> x$knotpoints[[1]]
       DE0001135101 DE0001141463 DE0001135218 DE0001135317              
0.0000     1.006027     2.380274     5.033425     9.234521 31.44657

First we used the estim_cs function that estimates the term structure of coupon bonds based on cubic splines (Ferstl-Haydn, 2010) and returns the knot points in a list with the knotpoints name. Please note that estim_cs works with a list—just like most functions in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required