Gifts from BAC ML and the Federal Reserve

May 17, 2011
By

(This article was first published on Timely Portfolio, and kindly contributed to R-bloggers)

Bank of America Merrill Lynch and the Federal Reserve Bank of St. Louis Fed continue to surprise me with even more gifts.  This time they added Emerging Market Bond Indexes with history back to 1998 (cannot see Asia Pacific Crisis of 1997-1998 but can see Argentina 2001-2002).  Data like this is extremely difficult to attain without significant subscription costs.

Since BAC ML and the Fed took it a step further, I feel equally obligated to extend my post Bank of America Merrill Lynch Bond Returns on St. Louis Fed to include some of this newly added data.

From TimelyPortfolio
From TimelyPortfolio
From TimelyPortfolio
From TimelyPortfolio

R code:

#thank you Bank of America Merrill Lynch and St. Louis Fed for this data

require(quantmod)
require(PerformanceAnalytics)
require(ggplot2)

#get Bank of America Merrill Lynch bond index data from St. Louis Fed
#use auto.assign = FALSE so we can use shorter names
MLAsiaEmCorp<-getSymbols("BAMLEMRACRPIASIATRIV",src="FRED",auto.assign=FALSE)
MLLatAmEmCorp<-getSymbols("BAMLEMRLCRPILATRIV", src="FRED", auto.assign=FALSE)
MLUSCorp<-getSymbols("BAMLCC0A0CMTRIV", src="FRED", auto.assign=FALSE)
MLBondIndexes<-na.omit(merge(ROC(MLAsiaEmCorp,1,type="discrete"),ROC(MLLatAmEmCorp,1,type="discrete"),ROC(MLUSCorp,1,type="discrete")))
colnames(MLBondIndexes)<-c("BAC ML Asia Emerging Corporate","BAC ML Latin America Emerging Corp","BAC ML US Corporate Master")

charts.PerformanceSummary(MLBondIndexes,ylog=TRUE,
    colorset=c("cadetblue","darkolivegreen3","gray70"),
    main="Bank of America Merrill Lynch Bond Indicies from St. Louis Fed")

#do some downside analysis on monthly returns
MLBondIndexes<-merge(monthlyReturn(MLAsiaEmCorp),monthlyReturn(MLLatAmEmCorp),monthlyReturn(MLUSCorp))
colnames(MLBondIndexes)<-c("BAC ML Asia Emerging Corporate","BAC ML Latin America Emerging Corp","BAC ML US Corporate Master")
downsideTable<-melt(cbind(rownames(table.DownsideRisk(MLBondIndexes)),table.DownsideRisk(MLBondIndexes)))
colnames(downsideTable)<-c("Statistic","BondIndex","Value")
ggplot(downsideTable, stat="identity", aes(x=Statistic,y=Value,fill=BondIndex)) + geom_bar(position="dodge") + coord_flip()

#ggplot annual returns
yearReturns<-na.omit(table.CalendarReturns(MLBondIndexes)[,(13:NCOL(table.CalendarReturns(MLBondIndexes)))])
yearReturns<-melt(cbind(rownames(yearReturns),yearReturns))
colnames(yearReturns)<-c("Year","BondIndex","Return")
ggplot(yearReturns, stat="identity", aes(x=Year,y=Return,fill=BondIndex)) + geom_bar(position="dodge")

#ggplot CAPM statistics
capmTable<-melt(cbind(rownames(table.CAPM(MLBondIndexes[,1:2],MLBondIndexes[,3])),table.CAPM(MLBondIndexes[,1:2],MLBondIndexes[,3])))
colnames(capmTable)<-c("Statistic","BondIndex","Return")
ggplot(capmTable, stat="identity", aes(x=Statistic,y=Return,fill=BondIndex)) + geom_bar(position="dodge") + coord_flip()

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

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.