Size: 501
Comment:
|
Size: 502
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 12: | Line 12: |
the the two-sided p-value for testing of the a,b Pearson correlation equals zero is outputted using pout (assuming 1000 simulations). | then the two-sided p-value for testing of the a,b Pearson correlation equals zero is outputted using pout (assuming 1000 simulations). |
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)
then 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