Plotting the investment grade spread
Aside from the risk-free rate changing through time, another determinant of the corporate bond yield is the size of the credit spread, which also changes through time. One way to observe this spread is to compare the yield on the highest rated investment grade bonds (Aaa rating) and the yield on the lowest investment grade bonds (Baa rating).
The investment grade (IG) spread can be viewed as the market's perception of how risky investing in bonds is at a certain point in time. The larger the IG spread, the more compensation investors demand for investing in riskier bonds.
In this exercise, you will plot the investment grade (IG) spread from January 2006 to September 2016. The object spread
contains the Aaa and Baa yields (generated using the quantmod
package).
This exercise is part of the course
Bond Valuation and Analysis in R
Exercise instructions
- Examine the first and last six elements of
spread
using calls tohead()
andtail()
. - Generate a
diff
column withinspread
that is equal to the difference between Baa yields (baa
) and Aaa yield (aaa
), converted to percentage points (* 100
). - Use
plot()
to view spread over time. Set thex
argument equal tospread$date
and set they
argument equal tospread$diff
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Examine first and last six elements in spread
head(___)
tail(___)
# Calculate spread$diff
spread$diff <-
# Plot spread
plot(x = ___,
y = ___,
type = "l",
xlab = "Date",
ylab = "Spread (bps)",
col = "red",
main = "Baa - Aaa Spread")