Skip to content

Instantly share code, notes, and snippets.

@mbusigin
Created October 10, 2016 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbusigin/c9e7524c872ab9d71876b2753abaf455 to your computer and use it in GitHub Desktop.
Save mbusigin/c9e7524c872ab9d71876b2753abaf455 to your computer and use it in GitHub Desktop.
Impute the Baa Spread using LQD, IEF and inverted 10s.
##
## Unfortunately, FRED no longer will be providing a whole bunch of interest rate series, principally Moody's.
## I use the Baa spread as the bedrock of my analysis, and although I can get a colleague to export the data from a BB terminal,
## I really needed to create a proxy so I can get data more quickly than that.
##
## The idea here is to impute the Baa spread from market inputs that we still have access to: 10s30s (because Baa spread has a
## duration spread embedded in it), the IEF/LQD ratio, and inverted 10s, in order to correct for convexity.
##
## The result is pretty decent: from 1986-2016, we get an R^2 of 0.9, RMSE of 0.26. I'm sure it could be improved upon, so let me know
## if you have any other ideas.
##
library(quantmod)
imputeAndMergeBaaSpread = function()
{
getSymbols( c("TLT", "IEF"), from="1950-01-01" );
fred( c("DGS10", "DGS30", "DBAA") );
imputedBaaSpread = -10.45630 + 13.25765*(IEF[,6]/LQD[,6]) + 0.01196*(DGS30-DGS10) + 1.67127*(1/DGS10)
a = merge(DBAA - DGS10, imputedBaaSpread)
names(a) = c("DBAA", "imputedBaaSpread")
a$s = a$imputedBaaSpread
a$s[is.na(a$s)] = a$DBAA[is.na(a$s)]
return(a$s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment