Historical Sources of Bond Returns with Shiller Data 1919-2011

[This article was first published on Timely Portfolio, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

And as usual, I always want a longer data set, so after a little playing with R-Excel, we can extend our historical sources of bond returns to 1919.  If nothing else, maybe you can find other uses for the Shiller Dataset in R.

From TimelyPortfolio

And as an added bonus, we can prepare a boxplot.

From TimelyPortfolio

As always, please criticize or make suggestions.


R code:


getSymbols(“BAA”,src=”FRED”) #load Corporate for credit from Fed Fred

#get Shiller data for inflation and US Treasury 10 year
URL <- "http://www.econ.yale.edu/~shiller/data/ie_data.xls”
shillerData <- read.xls(URL,sheet="Data",pattern="Rate GS10")
#strip out date(1), CPI(5), and GS10(7)
shillerData <- shillerData[,c(1,5,7)]
#get data starting in January 1919 to match with BAA xts series
shillerData <- shillerData[rownames(shillerData[which(shillerData$Date==format(index(BAA)[1],"%Y.%m")):NROW(shillerData),]),2:3]
shillerData <- xts(shillerData[1:NROW(BAA),1:2],order.by=index(BAA))

#get 12 month CPI change


chart.TimeSeries(bondReturnSources,legend.loc=”bottom”,main=”Historical Sources of Bond Returns”,ylab=”Yield as %”,colorset=c(“cadetblue”,”darkolivegreen3″,”goldenrod”,”gray70″))
#add source as caption
mtext(“Source: Federal Reserve FRED and Robert Shiller”,side=1,adj=0)

chart.Boxplot(bondReturnSources,main=”Historical Sources of Bond Returns”,colorset=c(“cadetblue”,”darkolivegreen3″,”goldenrod”,”gray70″))
mtext(“Source: Federal Reserve FRED and Robert Shiller”,side=1,adj=0)

To leave a comment for the author, please follow the link and comment on their blog: Timely Portfolio.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)