Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#get Japan yield data from the Ministry of Finance Japan
#data goes back to 1974
require(latticeExtra)
require(xtsExtra)
url <- "http://www.mof.go.jp/english/jgbs/reference/interest_rate/"
filenames <- paste("jgbcme",c("","_2010","_2000-2009","_1990-1999","_1980-1989","_1974-1979"),".csv",sep="")
#load all data and combine into one jgb data.frame
jgb <- read.csv(paste(url,filenames[1],sep=""),stringsAsFactors=FALSE)
for (i in 2:length(filenames)) {
jgb <- rbind(jgb,read.csv(paste(url,"/historical/",filenames[i],sep=""),stringsAsFactors=FALSE))
}
#now clean up the jgb data.frame to make a jgb xts
jgb.xts <- as.xts(data.matrix(jgb[,2:NCOL(jgb)]),order.by=as.Date(jgb[,1]))
#get Yen from the Fed
getSymbols("DEXJPUS",src="FRED")
p1986 <- xyplot(na.omit(merge(DEXJPUS,jgb.xts[,"X10"])),
lattice.options=theEconomist.opts(),
par.settings=theEconomist.theme(box="transparent"),
scale=list(y=list(rot=0)),
strip=strip.custom(factor.levels=c("USD/Yen","JGB 10y Yield","Rolling 1Y Correlation")),
xlab=NULL,
main="Japanese JGB 10Y Yield and Yen Since 1986")
p2005 <- xyplot(na.omit(merge(DEXJPUS,jgb.xts[,"X10"]))["2005::",],
lattice.options=theEconomist.opts(),
par.settings=theEconomist.theme(box="transparent"),
scale=list(y=list(rot=0)),
strip=strip.custom(factor.levels=c("USD/Yen","JGB 10y Yield","Rolling 1Y Correlation")),
xlab=NULL,
main="Japanese JGB 10Y Yield and Yen Since 2005")
p2012 <- xyplot(na.omit(merge(DEXJPUS,jgb.xts[,"X10"]))["2012::",],
lattice.options=theEconomist.opts(),
par.settings=theEconomist.theme(box="transparent"),
scale=list(y=list(rot=0)),
strip=strip.custom(factor.levels=c("USD/Yen","JGB 10y Yield")),
xlab=NULL,
main="Japanese JGB 10Y Yield and Yen Since 2012")
#######print top to bottom
print(p2012,position=c(0,0,1,0.35),more=TRUE)
print(p2005,position=c(0,0.33,1,0.67),more=TRUE)
print(p1986,position=c(0,0.66,1,1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.