Package 'YieldCurve'

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

Help Index


Modelling and estimation of the yield curve

Description

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.

Details

Package: YieldCurve
Type: Package
Version: 5
Date: 2022-09-30
License: GPL (>= 2)
LazyLoad: yes

DieboldLi

Author(s)

Sergio Salvino Guirreri

Maintainer: Sergio Salvino Guirreri <[email protected]>

References

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.

Examples

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

Yield curve data spot rate, AAA-rated bonds, maturities from 3 months to 30 years

Description

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.

Usage

data(ECBYieldCurve)

Format

It is an xts object with 32 interest rate at different maturities and 655 observations.

Source

ECB: https://www.ecb.europa.eu/stats/financial_markets_and_interest_rates/euro_area_yield_curves/html/index.en.html.

Examples

### 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()
}

Federal Reserve interest rates

Description

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.

Usage

data(FedYieldCurve)

Format

An object with class attributes xts.

Source

FED: https://www.federalreserve.gov/datadownload/Build.aspx?rel=H15.

Examples

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()
}

Estimation of the Nelson-Siegel parameters

Description

Returns the estimated coefficients of the Nelson-Siegel's model.

Usage

Nelson.Siegel( rate, maturity )

Arguments

rate

vector or matrix which contains the interest rates.

maturity

vector which contains the maturity ( in months) of the rate. The vector's length must be the same of the number of columns of the rate.

Details

The Nelson-Siegel's model to describe the yield curve is:

yt(τ)=β0t+β1t1exp(λτ)λτ+β2t(1exp(λτ)λτexp(λτ))y_t(\tau) = \beta_{0t} + \beta_{1t} \frac{1-\exp(-\lambda \tau)}{\lambda \tau} + \beta_{2t} \left(\frac{1-\exp(-\lambda \tau)}{\lambda \tau} - \exp(-\lambda \tau) \right)

Value

Returns a data frame with the estimated coefficients: β0t\beta_{0t}, β1t\beta_{1t}, β2t\beta_{2t}, and λ\lambda.

Author(s)

Sergio Salvino Guirreri

References

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.

See Also

NelsonSiegel, Svensson

Examples

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()

Interest rates of the Nelson-Siegel's model.

Description

Returns the interest rates by Nelson-Siegel's model.

Usage

NSrates(Coeff, maturity)

Arguments

Coeff

Vector or matrix of the beta's coefficients and lambda as the function Nelson.Siegel returns.

maturity

maturity of the yield curve of which want to return the interest rates.

Details

Coeff is a vector or matrix of the four coefficients of the Nelson-Siegel's model: (β0;β1;β2;λ)(\beta_0; \beta_1; \beta_2; \lambda).

Value

Return interest rates in matrix object with number of rows equal to nrow(betaCoeff) and number of columns equal to length(maturity).

Author(s)

Sergio Salvino Guirreri

References

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.

Examples

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()

Interest rates of the Svensson's model.

Description

Returns the interest rates by Svensson's model.

Usage

Srates(Coeff, maturity, whichRate = "Forward")

Arguments

Coeff

vector or matrix of the beta's coefficients and of λ1\lambda_1 and λ2\lambda_2.

maturity

maturity of the yield curve of which want to return the interest rates.

whichRate

which rate want to return: "Spot" or "Forward" rates.

Details

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.

Value

Return interest rates in matrix object with number of rows equal to nrow(Coeff) and number of columns equal to length(maturity).

Author(s)

Sergio Salvino Guirreri

References

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.

Examples

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()

Estimation of the Svensson parameters

Description

Returns the estimated coefficients of the Svensson's model.

Usage

Svensson(rate, maturity )

Arguments

rate

vector or matrix which contains the interest rates.

maturity

vector which contains the maturity (in months) of the rate. The vector's length must be the same of the number of columns of the rate.

Details

The Svensson's model to describe the forward rate is:

yt(τ)=β0+β1exp(τλ1)+β2τλ1exp(τλ1)+β3τλ2exp(τλ2)y_t(\tau) = \beta_{0} + \beta_{1} \exp\left( -\frac{\tau}{\lambda_1} \right) + \beta_2 \frac{\tau}{\lambda_1} \exp \left( -\frac{\tau}{\lambda_1} \right) + \beta_3 \frac{\tau}{\lambda_2} \exp \left( -\frac{\tau}{\lambda_2} \right)

The spot rate can be derived from forward rate and it is given by:

yt(τ)=β0+β11exp(τλ1)τλ1+β2[1exp(τλ1)τλ1exp(τλ1)]+β3[1exp(τλ2)τλ2exp(τλ2)]y_t(\tau) = \beta_0 + \beta_1 \frac{ 1- \exp( -\frac{\tau}{\lambda_1}) }{\frac{\tau}{\lambda_1} } + \beta_2 \left[\frac{ 1- \exp( -\frac{\tau}{\lambda_1}) }{\frac{\tau}{\lambda_1} } - \exp( -\frac{\tau}{\lambda_1}) \right] + \beta_3 \left[\frac{ 1- \exp(-\frac{\tau}{\lambda_2}) }{\frac{\tau}{\lambda_2} } - \exp( -\frac{\tau}{\lambda_2}) \right]

Value

Returns a data frame with the estimated coefficients: β0\beta_{0}, β1\beta_{1}, β2\beta_{2},β3\beta_{3}, λ1\lambda_1 and λ2\lambda_2.

Author(s)

Sergio Salvino Guirreri

References

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.

Examples

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()