Size: 491
Comment:
|
Size: 501
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 7: | Line 7: |
{{{ | |
Line 9: | Line 10: |
}}} |
Permutation test in R for a bivariate Pearson correlation
The permutation test recommended for testing if a correlation is zero can be used in R
Suppose we have two columns of data
a <- c(1,2,3) b <- c(3,6,5)
the the two-sided p-value for testing of the a,b Pearson correlation equals zero is outputted using pout (assuming 1000 simulations).
robs <- cor(a,b) repout <- replicate(1000,cor(a,sample(b))) rout<-(abs(repout)>robs) pout<-sum(rout=="TRUE")/1000