Title: | Modelling and Estimation of the Yield Curve |
---|---|
Description: | Modelling the yield curve with some parametric models. The models implemented are: Nelson, C.R., and A.F. Siegel (1987) <doi: 10.1086/296409>, Diebold, F.X. and Li, C. (2006) <doi: 10.1016/j.jeconom.2005.03.005> and Svensson, L.E. (1994) <doi: 10.3386/w4871>. The package also includes the data of the term structure of interest rate of Federal Reserve Bank and European Central Bank. |
Authors: | Sergio Salvino Guirreri |
Maintainer: | Sergio Salvino Guirreri <[email protected]> |
License: | GPL (>= 2) |
Version: | 5.1 |
Built: | 2024-12-13 06:30:34 UTC |
Source: | CRAN |
Modelling the yield curve with some parametric models. The models implemented are: Nelson-Siegel, Diebold-Li and Svensson. The package also includes the data of the term structure of interest rate of Federal Reserve Bank and European Central Bank.
Package: | YieldCurve |
Type: | Package |
Version: | 5 |
Date: | 2022-09-30 |
License: | GPL (>= 2) |
LazyLoad: | yes |
DieboldLi
Sergio Salvino Guirreri
Maintainer: Sergio Salvino Guirreri <[email protected]>
Diebold, F.X. and Li, C. (2006), Forecasting the Term Structure of Government Bond Yields, Journal of Econometrics, 130, 337-364.
Diebold, F.X., Ji, L. and Li, C. (2006), A Three-Factor Yield Curve Model: Non-Affine Structure, Systematic Risk Sources, and Generalized Duration, in L.R. Klein (ed.), Long-Run Growth and Short-Run Stabilization: Essays in Memory of Albert Ando. Cheltenham, U.K.: Edward Elgar, 240-274.
Nelson, C.R., and A.F. Siegel (1987), Parsimonious Modeling of Yield Curve, The Journal of Business, 60, 473-489.
Svensson, L.E. (1994), Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994, IMF Working Paper, WP/94/114.
### Nelson.Siegel function and Fed data-set ### data(FedYieldCurve) rate.Fed = first(FedYieldCurve,'5 month') maturity.Fed <- c(3/12, 0.5, 1,2,3,5,7,10) NSParameters <- Nelson.Siegel( rate= rate.Fed, maturity=maturity.Fed ) y <- NSrates(NSParameters[5,], maturity.Fed) plot(maturity.Fed,rate.Fed[5,],main="Fitting Nelson-Siegel yield curve", type="o") lines(maturity.Fed,y, col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) ### Svensson function and ECB data-set ### data(ECBYieldCurve) rate.ECB = ECBYieldCurve[1:5,] maturity.ECB = c(0.25,0.5,seq(1,30,by=1)) SvenssonParameters <- Svensson(rate.ECB, maturity.ECB) Svensson.rate <- Srates( SvenssonParameters ,maturity.ECB,"Spot") plot(maturity.ECB, rate.ECB[5,],main="Fitting Svensson yield curve", type="o") lines(maturity.ECB, Svensson.rate[5,], col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1)
### Nelson.Siegel function and Fed data-set ### data(FedYieldCurve) rate.Fed = first(FedYieldCurve,'5 month') maturity.Fed <- c(3/12, 0.5, 1,2,3,5,7,10) NSParameters <- Nelson.Siegel( rate= rate.Fed, maturity=maturity.Fed ) y <- NSrates(NSParameters[5,], maturity.Fed) plot(maturity.Fed,rate.Fed[5,],main="Fitting Nelson-Siegel yield curve", type="o") lines(maturity.Fed,y, col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) ### Svensson function and ECB data-set ### data(ECBYieldCurve) rate.ECB = ECBYieldCurve[1:5,] maturity.ECB = c(0.25,0.5,seq(1,30,by=1)) SvenssonParameters <- Svensson(rate.ECB, maturity.ECB) Svensson.rate <- Srates( SvenssonParameters ,maturity.ECB,"Spot") plot(maturity.ECB, rate.ECB[5,],main="Fitting Svensson yield curve", type="o") lines(maturity.ECB, Svensson.rate[5,], col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1)
Government bond, nominal, all triple A issuer companies. The maturities are 3 and 6 months and from 1 year to 30 years with frequency business day, provided by European Central Bank. The range date is from 2006-12-29 to 2009-07-24.
data(ECBYieldCurve)
data(ECBYieldCurve)
It is an xts
object with 32 interest rate at different maturities and 655 observations.
### plot ECB Yield Curve ### data(ECBYieldCurve) first(ECBYieldCurve,'3 day') last(ECBYieldCurve,'3 day') mat.ECB <- tau <- c(3/12,6/12,1:30) par(mfrow=c(2,3)) for( i in c(1,2,3,653,654,655) ){ plot(mat.ECB, ECBYieldCurve[i,], type="o", xlab="Maturity in years", ylab="IR values") title(main=paste("European Central Bank yield curve obeserved at",time(ECBYieldCurve[i], sep=" ") )) grid() }
### plot ECB Yield Curve ### data(ECBYieldCurve) first(ECBYieldCurve,'3 day') last(ECBYieldCurve,'3 day') mat.ECB <- tau <- c(3/12,6/12,1:30) par(mfrow=c(2,3)) for( i in c(1,2,3,653,654,655) ){ plot(mat.ECB, ECBYieldCurve[i,], type="o", xlab="Maturity in years", ylab="IR values") title(main=paste("European Central Bank yield curve obeserved at",time(ECBYieldCurve[i], sep=" ") )) grid() }
The data-set contains the interest rates of the Federal Reserve, from January 1982 to December 2012. The interest rates are Market yield on U.S. Treasury securities constant maturity (CMT) (more information on the Treasury yield curve can be found at the following website https://home.treasury.gov/policy-issues/financing-the-government/interest-rate-statistics) at different maturities (3 months, 6 months, 1 year, 2 years, 3 years, 5 years, 7 years and 10 years), quoted on investment basis and have been gathered with monthly frequency.
data(FedYieldCurve)
data(FedYieldCurve)
An object with class attributes xts
.
FED: https://www.federalreserve.gov/datadownload/Build.aspx?rel=H15.
require(xts) require(YieldCurve) data(FedYieldCurve) first(FedYieldCurve,'3 month') last(FedYieldCurve,'3 month') mat<-c(3/12, 0.5, 1,2,3,5,7,10) par(mfrow=c(2,3)) for( i in c(1,2,3,370,371,372) ){ plot(mat, FedYieldCurve[i,], type="o", xlab="Maturity in years", ylab="IR values") title(main=paste("Federal Reserve yield curve obeserved at",time(FedYieldCurve[i], sep=" ") )) grid() }
require(xts) require(YieldCurve) data(FedYieldCurve) first(FedYieldCurve,'3 month') last(FedYieldCurve,'3 month') mat<-c(3/12, 0.5, 1,2,3,5,7,10) par(mfrow=c(2,3)) for( i in c(1,2,3,370,371,372) ){ plot(mat, FedYieldCurve[i,], type="o", xlab="Maturity in years", ylab="IR values") title(main=paste("Federal Reserve yield curve obeserved at",time(FedYieldCurve[i], sep=" ") )) grid() }
Returns the estimated coefficients of the Nelson-Siegel's model.
Nelson.Siegel( rate, maturity )
Nelson.Siegel( rate, maturity )
rate |
vector or matrix which contains the interest rates. |
maturity |
vector which contains the maturity ( in months) of the |
The Nelson-Siegel's model to describe the yield curve is:
Returns a data frame with the estimated coefficients: ,
,
, and
.
Sergio Salvino Guirreri
Diebold, F.X. and Li, C. (2006), Forecasting the Term Structure of Government Bond Yields, Journal of Econometrics, 130, 337-364.
Diebold, F.X., Ji, L. and Li, C. (2006), A Three-Factor Yield Curve Model: Non-Affine Structure, Systematic Risk Sources, and Generalized Duration, in L.R. Klein (ed.), Long-Run Growth and Short-Run Stabilization: Essays in Memory of Albert Ando. Cheltenham, U.K.: Edward Elgar, 240-274.
Nelson, C.R., and A.F. Siegel (1987), Parsimonious Modeling of Yield Curve, The Journal of Business, 60, 473-489.
NelsonSiegel, Svensson
data(FedYieldCurve) maturity.Fed <- c(3/12, 0.5, 1,2,3,5,7,10) NSParameters <- Nelson.Siegel( rate=first(FedYieldCurve,'10 month'), maturity=maturity.Fed) y <- NSrates(NSParameters[5,], maturity.Fed) plot(maturity.Fed,FedYieldCurve[5,],main="Fitting Nelson-Siegel yield curve", xlab=c("Pillars in months"), type="o") lines(maturity.Fed,y, col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) grid()
data(FedYieldCurve) maturity.Fed <- c(3/12, 0.5, 1,2,3,5,7,10) NSParameters <- Nelson.Siegel( rate=first(FedYieldCurve,'10 month'), maturity=maturity.Fed) y <- NSrates(NSParameters[5,], maturity.Fed) plot(maturity.Fed,FedYieldCurve[5,],main="Fitting Nelson-Siegel yield curve", xlab=c("Pillars in months"), type="o") lines(maturity.Fed,y, col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) grid()
Returns the interest rates by Nelson-Siegel's model.
NSrates(Coeff, maturity)
NSrates(Coeff, maturity)
Coeff |
Vector or matrix of the beta's coefficients and lambda as the function |
maturity |
maturity of the yield curve of which want to return the interest rates. |
Coeff
is a vector or matrix of the four coefficients of the Nelson-Siegel's model: .
Return interest rates in matrix object with number of rows equal to nrow(betaCoeff)
and number of columns equal to length(maturity)
.
Sergio Salvino Guirreri
Diebold, F.X. and Li, C. (2006), Forecasting the Term Structure of Government Bond Yields, Journal of Econometrics, 130, 337-364.
Diebold, F.X., Ji, L. and Li, C. (2006), A Three-Factor Yield Curve Model: Non-Affine Structure, Systematic Risk Sources, and Generalized Duration, in L.R. Klein (ed.), Long-Run Growth and Short-Run Stabilization: Essays in Memory of Albert Ando. Cheltenham, U.K.: Edward Elgar, 240-274.
Nelson, C.R., and A.F. Siegel (1987), Parsimonious Modeling of Yield Curve, The Journal of Business, 60, 473-489.
data(FedYieldCurve) maturity.Fed <- c(3/12, 0.5, 1,2,3,5,7,10) NSParameters <- Nelson.Siegel( rate = first(FedYieldCurve,'10 month'), maturity=maturity.Fed ) y <- NSrates(NSParameters[5,],maturity.Fed) plot(maturity.Fed,FedYieldCurve[10,],main="Fitting Nelson-Siegel yield curve", type="o") lines(maturity.Fed,y, col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) grid()
data(FedYieldCurve) maturity.Fed <- c(3/12, 0.5, 1,2,3,5,7,10) NSParameters <- Nelson.Siegel( rate = first(FedYieldCurve,'10 month'), maturity=maturity.Fed ) y <- NSrates(NSParameters[5,],maturity.Fed) plot(maturity.Fed,FedYieldCurve[10,],main="Fitting Nelson-Siegel yield curve", type="o") lines(maturity.Fed,y, col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) grid()
Returns the interest rates by Svensson's model.
Srates(Coeff, maturity, whichRate = "Forward")
Srates(Coeff, maturity, whichRate = "Forward")
Coeff |
vector or matrix of the beta's coefficients and of |
maturity |
maturity of the yield curve of which want to return the interest rates. |
whichRate |
which rate want to return: "Spot" or "Forward" rates. |
Coeff
is a vector or matrix of the four coefficients of the Svensson's model, while lambdaValues
is a vector or matrix of two lambda values of Svensson's model.
Return interest rates in matrix object with number of rows equal to nrow(Coeff)
and number of columns equal to length(maturity)
.
Sergio Salvino Guirreri
Svensson, L.E. (1994), Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994, IMF Working Paper, WP/94/114.
Nelson, C.R., and A.F. Siegel (1987), Parsimonious Modeling of Yield Curve, The Journal of Business, 60, 473-489.
data(ECBYieldCurve) rate.ECB = first(ECBYieldCurve,'2 day') maturity.ECB = c(0.25,0.5,seq(1,30,by=1)) SvenssonParameters <- Svensson(rate.ECB, maturity.ECB) Svensson.rate <- Srates( SvenssonParameters ,maturity.ECB,"Spot") plot(maturity.ECB, last(rate.ECB,'1 day'),main="Fitting Svensson yield curve", xlab=c("Pillars in years"), ylab=c("Rates"),type="o") lines(maturity.ECB, last(Svensson.rate,'1 day'), col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) grid()
data(ECBYieldCurve) rate.ECB = first(ECBYieldCurve,'2 day') maturity.ECB = c(0.25,0.5,seq(1,30,by=1)) SvenssonParameters <- Svensson(rate.ECB, maturity.ECB) Svensson.rate <- Srates( SvenssonParameters ,maturity.ECB,"Spot") plot(maturity.ECB, last(rate.ECB,'1 day'),main="Fitting Svensson yield curve", xlab=c("Pillars in years"), ylab=c("Rates"),type="o") lines(maturity.ECB, last(Svensson.rate,'1 day'), col=2) legend("topleft",legend=c("observed yield curve","fitted yield curve"), col=c(1,2),lty=1) grid()
Returns the estimated coefficients of the Svensson's model.
Svensson(rate, maturity )
Svensson(rate, maturity )
rate |
vector or matrix which contains the interest rates. |
maturity |
vector which contains the maturity (in months) of the |
The Svensson's model to describe the forward rate is:
The spot rate can be derived from forward rate and it is given by:
Returns a data frame with the estimated coefficients: ,
,
,
,
and
.
Sergio Salvino Guirreri
Svensson, L.E. (1994), Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994, IMF Working Paper, WP/94/114.
Nelson, C.R., and A.F. Siegel (1987), Parsimonious Modeling of Yield Curve, The Journal of Business, 60, 473-489.
data(ECBYieldCurve) maturity.ECB <- c(0.25,0.5,seq(1,30,by=1)) A <- Svensson(ECBYieldCurve[1:10,], maturity.ECB ) Svensson.rate <- Srates( A, maturity.ECB, "Spot" ) plot(maturity.ECB, Svensson.rate[5,],main="Fitting Svensson yield curve", xlab=c("Pillars in years"), type="l", col=3) lines( maturity.ECB, ECBYieldCurve[5,],col=2) legend("topleft",legend=c("fitted yield curve","observed yield curve"), col=c(3,2),lty=1) grid()
data(ECBYieldCurve) maturity.ECB <- c(0.25,0.5,seq(1,30,by=1)) A <- Svensson(ECBYieldCurve[1:10,], maturity.ECB ) Svensson.rate <- Srates( A, maturity.ECB, "Spot" ) plot(maturity.ECB, Svensson.rate[5,],main="Fitting Svensson yield curve", xlab=c("Pillars in years"), type="l", col=3) lines( maturity.ECB, ECBYieldCurve[5,],col=2) legend("topleft",legend=c("fitted yield curve","observed yield curve"), col=c(3,2),lty=1) grid()