Diff for "FAQ/permy" - CBU statistics Wiki
location: Diff for "FAQ/permy"
Differences between revisions 18 and 19
Revision 18 as of 2013-01-08 10:56:38
Size: 1223
Editor: PeterWatson
Comment:
Revision 19 as of 2013-03-08 10:17:25
Size: 1227
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The permutation test recommended by Bishara and Hittner (2012) for samples of under 10 for testing if a correlation is zero can be obtained in R. This uses an approach which randomly permutes the values of one of the variables being correlated (e.g. b) to compare with the observed correlation. This corresponds to sampling without replacement (see [http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient here]). Note that this is not an 'exact' test which would use exactly all n! permutations of b to produce correelations to compare with the observed correlation (see for example [http://tolstoy.newcastle.edu.au/R/help/05/12/16699.html here]). The permutation test recommended by Bishara and Hittner (2012) for samples of under 10 for testing if a correlation is zero can be obtained in R. This uses an approach which randomly permutes the values of one of the variables being correlated (e.g. b) to compare with the observed correlation. This corresponds to sampling without replacement (see [[http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient|here]]). Note that this is not an 'exact' test which would use exactly all n! permutations of b to produce correelations to compare with the observed correlation (see for example [[http://tolstoy.newcastle.edu.au/R/help/05/12/16699.html|here]]).

Permutation test in R for a bivariate Pearson correlation

The permutation test recommended by Bishara and Hittner (2012) for samples of under 10 for testing if a correlation is zero can be obtained in R. This uses an approach which randomly permutes the values of one of the variables being correlated (e.g. b) to compare with the observed correlation. This corresponds to sampling without replacement (see here). Note that this is not an 'exact' test which would use exactly all n! permutations of b to produce correelations to compare with the observed correlation (see for example here).

Suppose we have two columns of data

a <- c(1,2,3)
b <- c(3,6,5)

then the two-sided p-value testing if the a,b Pearson correlation equals zero may be outputted in pout (assuming 1000 simulations) using the below.

robs <- cor(a,b)
repout <- replicate(1000,cor(a,sample(b)))
rout<-(abs(repout)>robs)
pout<-sum(rout=="TRUE")/1000

The 2.5 and 97.5 percentiles of 'repout' computed as above provide a 95% Confidence Interval for the permuted correlation.

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