public
Created

  • Download Gist
bonds zero bound.r
R
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
require(latticeExtra)
require(directlabels)
require(reshape2)
require(quantmod)
 
getSymbols("VUSTX",from="1990-01-01")
getSymbols("VBMFX",from="1990-01-01")
 
bonds.tr <- merge(ROC(VUSTX[,6],250),ROC(VBMFX[,6],250))
colnames(bonds.tr) <- c("VanguardLongTsy","VanguardTotBnd")
bonds.melt <- melt(as.data.frame(cbind(as.Date(index(bonds.tr)),coredata(bonds.tr))),id.vars=1)
colnames(bonds.melt) <- c("date","fund","totret250")
bonds.melt$date <- as.Date(bonds.melt$date)
 
asTheEconomist(
horizonplot(totret250~date|fund,origin=0,horizonscale=0.05,
data=bonds.melt,
strip=TRUE,strip.left=FALSE,par.strip.text=list(cex=1.1),
layout=c(1,2),
main="Vanguard Bond Funds 250 Day Total Return"))
direct.label(
xyplot(bonds.tr,screens=1,
ylim=c(-0.35,0.35),scales=list(y=list(rot=0)),
col=theEconomist.theme()$superpose.line$col,
par.settings=theEconomist.theme(box="transparent"),
lattice.options=theEconomist.opts(),
xlab=NULL,
main="Vanguard Bond Funds 250 Day Total Return"),
list("last.points",hjust=1,cex=1.2))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.