Permutation tests

TODO

  • link to combinatorics

Install required packages

coin, e1071

Two-sample \(t\)-test / one-way ANOVA for independent groups

Not limited to just two independent samples.

Using package coin


    Exact Two-Sample Fisher-Pitman Permutation Test

data:  DV by IV (A, B)
Z = 0.13559, p-value = 0.5602
alternative hypothesis: true mu is less than 0

Compare with parametric \(t\)-test

[1] 0.5510091

Manual exact test

[1] 0.55338

Diagram: permutation distribution

Check density of permutation distribution.

plot of chunk rerResamplingPerm01
plot of chunk rerResamplingPerm01

QQ-plot against standard normal distribution.

plot of chunk rerResamplingPerm02
plot of chunk rerResamplingPerm02

Empirical cumulative distribution function.

plot of chunk rerResamplingPerm03
plot of chunk rerResamplingPerm03

Two-sample \(t\)-test / one-way ANOVA for dependent groups

Not limited to just two dependent samples.

Using package coin


    Approximative Two-Sample Fisher-Pitman Permutation Test

data:  DV by IV (pre, post) 
     stratified by id
Z = -2.1232, p-value = 0.0138
alternative hypothesis: true mu is less than 0
[1] 0.0129621

Manual exact test

[1] 0.01391602

Independence of two variables

Fisher’s exact test

[1] 0.6428571

Manual exact test

[1] 0.6428571

Useful packages

Packages resample and vegan provide more ways to implement flexible permutation strategies for various designs.

Detach (automatically) loaded packages (if possible)

Get the article source from GitHub

R markdown - markdown - R code - all posts