[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.

As the Yen and Japan continue to get more interesting in my mind, I just wanted to resurrect some posts that I have done on Japan and the Yen and sort them by my favorites.

Just to add a chart, here is one using data from the Federal Reserve Bank of St. Louis (FRED).  While the extreme correlation between the Yen and the S&P 500 has limited the opportunity available in the Yen, the correlation has recently weakened as Japanese deficits have worsened and the Yen stopped getting stronger.

 From TimelyPortfolio

R code:

require(latticeExtra)
require(quantmod)

getSymbols(“DEXJPUS”,src=”FRED”)
getSymbols(“SP500″, src=”FRED”)

asTheEconomist(xyplot(DEXJPUS,main=”US Dollars for Japanese Yen Since 1970\nSource: Federal Reserve Bank of St. Louis”))

#merge the weekly returns of Yen and SP500
ret <- na.omit(merge(weeklyReturn(DEXJPUS),weeklyReturn(SP500)))
#use the rolling correlation method from PerformanceAnalytics chart.RollingCorrelation
rollcor <- as.xts(rollapply(ret, width = 208, FUN = function(x) cor(x[,
1, drop = FALSE], x[, 2, drop = FALSE]), by = 1,
by.column = FALSE, na.pad = FALSE, align = “right”))
xyplot(na.omit(merge(SP500,rollcor,DEXJPUS)),col=brewer.pal(“RdBu”,n=9)[c language=”(9,2,8)”][/c],
lattice.options=theEconomist.opts(),
par.settings=theEconomist.theme(box=”transparent”),
scale=list(y=list(rot=0)),
xlab=NULL,
strip=strip.custom(factor.levels=c(“S&P 500″,”Correlation (Rolling 4 Year) S&P 500 and USD/Yen”,”USD/Japanese Yen”)),
main = “S&P 500 and USD/Yen Since 1970\nSource: Federal Reserve Bank of St. Louis”)