The yield curve can help make a wide range of financial decisions. The yield curve reflects the bond market’s consensus opinion of future economic activity, levels of inflation and interest rates. It’s very difficult to outperform the market, so prudent investors should look to employ valuable tools like the yield curve whenever possible in their decision-making processes.
The bond market is a great predictor of future economic activity and future levels of inflation, both of which directly affect the price of everything from stocks and real estate to household items.
http://www-stat.wharton.upenn.edu/~stine/research/penn_fin_club.pdf.
A Primer on Interest Rates and Bond Yields
Interest rates and bond yields are highly correlated, and sometimes the terms are used interchangeably.
An interest rate might be thought of as the rate at which money can be borrowed in the form pf a loan and, while most bonds have an interest rate that determines their coupon payments, the true cost of borrowing or investing in bonds is determined by their current yields.
A bond’s yield is simply the discount rate that can be used to make the present value of all of a bond’s cash flows equal to its price. A bond’s price is the sum of the present value of each cash flow that will ever be received from the investment.
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(YieldCurve)
## Warning: package 'YieldCurve' was built under R version 3.4.2
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
##
## first, last
library(ustyc)
## Warning: package 'ustyc' was built under R version 3.4.2
yc <- getYieldCurve()
## Download and parse complete. Converting to list...
## List conversion complete. Converting to frame...
## Frame conversion complete.
yc_xts = xts(yc$df, order.by=as.Date(rownames(yc$df)))
save(yc_xts, file = "yc_xts.rda")
load("yc_xts.rda")
x10y <- yc_xts %>% subset(select = "BC_10YEAR")
x3m <- yc_xts %>% subset(select = "BC_3MONTH")
x10y1 <- x10y['2002/2017']
x3m1 <- x3m['2002/2017']
x10y2 <- x10y['2017']
x3m2 <- x3m['2017']
isNotZero = apply(x10y1, 1, function(row) all(row != 0 ))
x10y1z <- x10y1[isNotZero,]
isNotZero = apply(x3m1, 1, function(row) all(row != 0 ))
x3m1z <- x3m1[isNotZero,]
plot.xts(cbind(x10y1z,x3m1z), col = c("red", "blue"),ylim=c(0,6), main="10 year and 3 month rate")
title(main="The interest rates of the Federal Reserve",
xlab="Date", ylab="Interest Rate by %")
legend("topleft",legend=c("10 Years Yield","3 Months Yield"),
col=c("red", "blue"),lty=1)
# Remove zero
isNotZero = apply(x10y2, 1, function(row) all(row != 0 ))
x10y2z <- x10y2[isNotZero,]
isNotZero = apply(x3m2, 1, function(row) all(row != 0 ))
x3m2z <- x3m2[isNotZero,]
plot.xts(cbind(x10y2z,x3m2z), ylim=c(0,3), col = c("red", "blue"), main="10 year and 3 month rate")
title(main="The interest rates of the Federal Reserve",
xlab="Date by Month", ylab="Interest Rate by %")
legend("topleft",legend=c("10 Years Yield","3 Months Yield"),
col=c("red", "blue"),lty=1)
The yield curve is one of the most closely watched charts in finance, as it describes the relationship between short- and long-term interest rates. Normally, the yield curve is upward sloping, meaning that investors are paid more to lock up their money for longer periods. However, on occasion, the yield curve can flip, resulting in an inverted yield curve that can significantly impact returns for fixed income and equity investors alike.
The yield curve is a graph of the interest rates, or yields, that investors can earn from buying different maturities of a particular type of debt. Normally, when people talk about the yield curve, they’re referring to U.S. Treasuries, or the debt issued by the U.S. government through the Department of the Treasury. The yield curve plots the returns for three-month, six-month, one-year, two-year, five-year, 10-year and 30-year Treasuries.
require(ustyc)
yc <- getYieldCurve()
## Download and parse complete. Converting to list...
## List conversion complete. Converting to frame...
## Frame conversion complete.
summary(yc)
## rows month year
## "6972" "All" "All"
## updated
## "2017-11-07T21:35:47Z"
head(yc$df)
## BC_1MONTH BC_3MONTH BC_6MONTH BC_1YEAR BC_2YEAR BC_3YEAR
## 1990-01-02 NA 7.83 7.89 7.81 7.87 7.90
## 1990-01-03 NA 7.89 7.94 7.85 7.94 7.96
## 1990-01-04 NA 7.84 7.90 7.82 7.92 7.93
## 1990-01-05 NA 7.79 7.85 7.79 7.90 7.94
## 1990-01-08 NA 7.79 7.88 7.81 7.90 7.95
## 1990-01-09 NA 7.80 7.82 7.78 7.91 7.94
## BC_5YEAR BC_7YEAR BC_10YEAR BC_20YEAR BC_30YEAR
## 1990-01-02 7.87 7.98 7.94 NA 8.00
## 1990-01-03 7.92 8.04 7.99 NA 8.04
## 1990-01-04 7.91 8.02 7.98 NA 8.04
## 1990-01-05 7.92 8.03 7.99 NA 8.06
## 1990-01-08 7.92 8.05 8.02 NA 8.09
## 1990-01-09 7.92 8.05 8.02 NA 8.10
## BC_30YEARDISPLAY
## 1990-01-02 0
## 1990-01-03 0
## 1990-01-04 0
## 1990-01-05 0
## 1990-01-08 0
## 1990-01-09 0
require(xts)
require(lattice)
## Loading required package: lattice
xt = xts(yc$df,order.by=as.Date(rownames(yc$df)))
xyplot.ts(xt,scales=list(y=list(relation="same")),ylab="Yield (%)")
xyplot.ts(xt,superpose=TRUE,auto.key=list(columns=4),ylab="Yield (%)")
treasury.maturity <- c(1/12,3/12,6/12,1,2,3,5,7,10,20,30)
mv = max(tail(yc$df,n=180))
g <- gray.colors(6,start=0.3,end=0.9,gamma=2.2)
plot(treasury.maturity,
yc$df[nrow(yc$df),-12],
type="l",
main="US Treasury Constant Maturity Yield Curve",
sub="Current Values And Change Over Six Months",
xlab="Maturity (yr)",
ylab="Yield (%)",
lwd=2,
ylim=c(0.0,mv),
col="darkred")
points(treasury.maturity,
as.numeric(yc$df[nrow(yc$df),-12]),
col="darkred")
for ( i in 1:6 ) {
lines(treasury.maturity,
as.numeric(yc$df[nrow(yc$df)-i*30,-12]),
type="l",
col=g[i])
}
mtext(yc$updated,side=3,col="darkgray",cex=0.7)
Good estimates of the term structure of interest rates (also known as the spot rate curve or the zero bond yield curve) are of the utmost importance to investors and policy makers.
The Nelson-Siegel model consists of three parts reflecting three factors: a constant (f0), an exponential decay function (f1) and a Laguerre function (f2). The constant represents the (long-term) interest rate level. http://www.efmaefm.org/0EFMAMEETINGS/EFMA%20ANNUAL%20MEETINGS/2010-Aarhus/papers/Smoothed_Bootstrap_-_Nelson-Siegel_Revisited_June_2010.pdf.
The term structure of interest rates is defined as the relationship between the yields of default-free pure discount (zero-coupon) bonds and their time to maturity. The term structure is not always directly observable because, with the exception of short-term treasury-bills, most of the substitutes for default-free bonds (government bonds) are not pure discount bonds. Therefore, an estimation methodology is required to derive the zero coupon yield curves from observable data. If we deal with approximations of empirical data to create yield curves it is necessary to choose suitable mathematical functions. The first class is parametric models. This class of function-based models includes the model proposed by Nelson and Siegel (1987) and its extension by Svensson (1994). https://www.vse.cz/polek/download.php?jnl=efaj&pdf=9.pdf.
### Nelson.Siegel function and Fed data-set ###
data(FedYieldCurve)
rate.Fed = first(FedYieldCurve,'5 month')
maturity.Fed <- c(0.25, 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)