# Why does the bootstrapped correlation revolve around zero while the original correlation $\approx 0.52$?

I have two data series containing 132 log-returns. One is for EURUSD, the other is for NZDUSD. The head() function shows you how some of the data looks. The correlation coefficient between the two, as calculated by cor() is $0.5178912$.

To get a better sense of the correlation coefficient I bootstrap it by running cor() 1000 times on different 132 long samples. I run this in a loop and update euro.nzd.corr on every iteration. This is the R code I'm using:

head(euro)
[1] -0.001257862 -0.011637970  0.002428757  0.003602590 -0.003457319 -0.002012728
[1]  0.008773255 -0.007744927  0.005498693  0.005642524 -0.000896363  0.003449576
cor(euro,nzd)
[1] 0.5178912
euro.nzd.corr <- numeric(1000)
for(i in 1:1000){
euro.nzd.corr[i] = cor(euro[sample(132,132,replace=TRUE)],nzd[sample(132,132,replace=TRUE)])
}
plot(density(euro.nzd.corr), lwd=3, col="steelblue")


Once I have the data, I plot the density chart, and get this:

Bootstrapped data has mean $\approx 0$ and mostly spreads between $-0.3$ and $0.3$. Where has the initial cor() result of $0.5178912$ gone? What am I to make of this? That it is better to conclude the two variables are uncorrelated versus correlated with a coefficient of $\approx 0.52$? Have I made any coding mistakes, or is the applied methodology simply flawed?

There is an obvious reason for that: You are sampling from both series separately, thus destroying any correlation. You probably want to sample pairs, not observations in each series, e.g.

index <- sample(132,132, replace=TRUE)
euro.nzd.corr[i] = cor(euro[index], nzd[index])


Fixing your code should allow you to recover a distribution centered on .5 but you might want to look up some literature before relying on these inferences as there are some niceties about bootstrapping correlations. As @NickCox pointed out, the fact that both set of observations are times series also creates further difficulties. You should be able to find a lot of material on all that.

• Add that bootstrapping time series is deeply problematic. – Nick Cox Jul 29 '13 at 9:49
• +1, Ninja'd me as well (I was up to "It looks to me like your bootstrap function is not respecting the paired-ness of the two currency objects") – James Stanley Jul 29 '13 at 9:50
• @NickCox Good point, I edited my answer to highlight it. – Gala Jul 29 '13 at 9:58
• There is a nice symmetry here. My initial comment was purely about time series; I didn't spot the point you caught on separate sampling. – Nick Cox Jul 29 '13 at 10:00
• +1, however (setting aside @NickCox's good point about time-series), I wouldn't necessarily say that sampling from 2 vectors separately is a mistake. I would say the mistake is in understanding / interpretation. Bootstrapping by sampling from 2 vectors separately can be a perfectly good way to estimate the null sampling distribution. – gung Jul 29 '13 at 21:56