Diff for "FAQ/permy" - CBU statistics Wiki
location: Diff for "FAQ/permy"
Differences between revisions 11 and 12
Revision 11 as of 2013-01-07 13:36:54
Size: 502
Editor: PeterWatson
Comment:
Revision 12 as of 2013-01-07 13:39:22
Size: 505
Editor: PeterWatson
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

None: FAQ/permy (last edited 2013-03-08 10:17:25 by localhost)