Size: 502
Comment:
|
Size: 505
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
The permutation test recommended for testing if a correlation is zero can be used in R | The permutation test recommended by for testing if a correlation is zero can be used in R |
Permutation test in R for a bivariate Pearson correlation
The permutation test recommended by 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