Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

if I have two uniform random variables $X$ and $Y$, and I sample $N$ values for each, what's the probability of getting an $r$ Pearson's correlation coefficient (or Spearman correlation) between them of at least $x$? In other words what is the distribution of the $r$ values in this case?

Similarly, what if $X$ and $Y$ were normal RVs, each with its own mean and standard deviation ($X_\mu$, $X_\sigma$ and $Y_\mu$, $Y_\sigma$, respectively), then what would the distribution of $r$ be as a function of these parameters?

share|improve this question
2  
Wikipedia gives the distribution of $r$ for jointly normal variables at en.wikipedia.org/wiki/…. Correlation does not depend on means or standard deviations, so the distribution of $r$ is the same regardless of the parameters mentioned in the last paragraph. –  whuber Oct 10 '12 at 19:20
    
Are you asking what the sampling distribution for r would look like if X and Y are uncorrelated? Or are you interested in the sampling distribution of r if the population correlation is some know, non-zero value? –  Joel W. Oct 10 '12 at 19:29
    
@JoelW. I'm assuming that X and Y are independent and each follow their own distribution (in first case, both are uniform over the same space, in second case each is a normal with its own mean and variance). So yes I am asking what the sampling distribution would look like assuming X and Y are independent, and we only know how they are each distributed. –  user248237 Oct 11 '12 at 3:08
    
@whuber: but intuitively, if you sample 10 points from a normal X with very tight sdev and 10 from a very 'noisy' Y random variable with large sdev, and try to compute their correlation, shouldn't your sampling distribution of R^2 be affected by this? it seems like the probability of getting a particular R^2 in this case would be different than in case where X and Y have very tight sdevs –  user248237 Oct 11 '12 at 3:28
2  
No, that's not the case. The Pearson correlation coefficient is mathematically constructed to have no dependence on either the mean or variance of the underlying distribution. Your intuition might be improved by thinking of the correlation coefficient as a property of the standardized variables. –  whuber Oct 11 '12 at 12:59

1 Answer 1

up vote 2 down vote accepted

Not sure this answers your Q, but...Generally, with sample sizes above a few dozen and with many such samples, the r distribution in both the normal and uniform cases will be itself normal, centering on zero. The exact shape of the distribution will depend on how many values you sample and how many samples you take (how many trials you run). If you use R you can try out different values to replace 100 (the size of each sample) and 50,000 (the number of trials) in the code below. (The "f2" is merely a rounding/formatting function of mine):

#NORMAL RANDOM
x=rnorm(100000)
y=rnorm(100000)
r=rep(1,50000)
for (i in 1:50000)  {
x.i = sample(x, 100, replace=T)
y.i = sample(y, 100, replace=T)
r[i]=cor(x.i,y.i)
}
hist(r,main="Simulated r, normal random samples")
hist(r,xlim=c(-.5,.5),legend(locator(1),c("SD=",
f2(sd(r)))))

#UNIFORM RANDOM
windows()
x=runif(100000)
y=runif(100000)
r=rep(1,50000)
for (i in 1:50000)  {
x.i = sample(x, 100, replace=T)
y.i = sample(y, 100, replace=T)
r[i]=cor(x.i,y.i)
}
hist(r,main="Simulated r, normal random samples")
hist(r,main="Simulated r",xlim=c(-.5,.5),legend(locator(1),c("SD=",
f2(sd(r)))))

enter image description here

I'm new to R and suggestions for improvements are most welcome. For instance, there ought to be a way to get the 2nd histogram to appear without ordering up the first one.

share|improve this answer
1  
In response to your last question: use par(mfrow = c(1,2)) to get two plots on the same line or par(mfrow = c(2,1)) to get two plots, one underneath the other. –  wcampbell Oct 10 '12 at 20:17
    
Thanks, I'll see whether I can figure out the new error messages I'm getting :-) With the code above I found I had to "initialize" a graph window before the full graph with legend would appear (otherwise, "Error in locator(1) : plot.new has not been called yet"). –  rolando2 Oct 10 '12 at 21:41
    
This is a nice answer and intuitive, but I was looking for more an analytical solution or an explanation of when there is / isn't one -- and in particular, how the solution depends on the parameterization of the distribution that X and Y follow –  user248237 Oct 11 '12 at 3:07
2  
f <- function(n, ntrials=1) { xy <- array(runif(ntrials*n*2), dim=c(n, 2, ntrials)); apply(xy, 3, function(z) cor(z[,1], z[,2])) }; par(mfrow=c(3,3)); tmp <- sapply(c(3:6,8,10,12,15,20), function(n) hist(f(n, 10^3), xlab="Pearson rho", main=sprintf("Sample size %d", n))) –  whuber Oct 11 '12 at 13:19
1  
@whuber - if you added this for my benefit, thank you. I wonder how much more study I'll need to be able to follow it :-) –  rolando2 Oct 14 '12 at 22:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.