Permutation/shuffle tests (spynal.randstats.permutation)

Nonparametric permutation/shuffle/randomization statistics

one_sample_randomization_test(data, axis=0, mu=0, stat='t', tail='both', n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Mass univariate 1-sample randomization test

Parameters and returns are same as one_sample_test()

For each random resample, each observation is randomly assigned a sign (+ or -), similar to a Fisher sign test. The same stat is then computed on the resampled data to estimate the distrubution under the null hypothesis, and the stat value for the actual observed data is compared to this.

References

Manly (1997) “Randomization, Bootstrap and Monte Carlo Methods in Biology” ch.6.2

one_sample_permutation_test(data, axis=0, mu=0, stat='t', tail='both', n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Alias of one_sample_randomization_test(). See there for details.

paired_sample_permutation_test(data1, data2, axis=0, d=0, stat='t', tail='both', n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Mass univariate paired-sample permutation test

Parameters and returns are same as paired_sample_test()

For each random resample, each paired-difference observation is randomly assigned a sign (+ or -), which is equivalent to randomly permuting each pair between samples (data1 vs data2). The same stat is then computed on the resampled data to estimate the distrubution under the null hypothesis, and the stat value for the actual observed data is compared to this.

References

Manly (1997) “Randomization, Bootstrap and Monte Carlo Methods in Biology” ch.6.1

paired_sample_association_permutation_test(data1, data2, axis=0, stat='r', tail='both', n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Mass bivariate permutation test of association (eg correlation) between two paired samples

Parameters and returns are same as paired_sample_association_test()

Observations are randomly permuted across one of the paired samples (data1 vs data2) relative to the other, to eliminate any association between them while preserving the marginal distributions of each sample. The same stat is then computed on the resampled data to estimate the distrubution under the null hypothesis, and the stat value for the actual observed data is compared to this.

two_sample_permutation_test(data1, data2, axis=0, stat='t', tail='both', n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Mass univariate permutation two-sample test

Parameters and returns are same as two_sample_test()

Observations are permuted across the two samples (data1 vs data2). The data is pooled across data1 and and data2, and for each random resample, n1 and n2 observations are extracted from the pooled and form the resampled versions of data1 and data2, respectively. The same stat is then computed on the resampled data to estimate the distrubution under the null hypothesis, and the stat value for the actual observed data is compared to this.

References

Manly (1997) “Randomization, Bootstrap and Monte Carlo Methods in Biology” ch.6.3

one_way_permutation_test(data, labels, axis=0, stat='F', tail='right', groups=None, n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Mass univariate one-way permutation test

Parameters and returns are same as one_way_test()

Observation labels are randomly shuffled and allocated to groups with the same n’s as in the actual observed data.

References

Manly (1997) “Randomization, Bootstrap and Monte Carlo Methods in Biology” ch.7.1

two_way_permutation_test(data, labels, axis=0, stat='F', tail='right', groups=None, n_resamples=10000, seed=None, return_stats=False, keepdims=True, **kwargs)

Mass univariate permutation 2-way test

Parameters and returns are same as two_way_test()

Observation labels are randomly shuffled and allocated to groups (ANOVA cells) with the same n’s as in the actual observed data.

We resample the entire row of labels for each observation, which effectively shuffles observations between specific combinations of groups/factor levels (ANOVA “cells”) cf. recommendation in Manly book

References

Manly (1997) “Randomization, Bootstrap and Monte Carlo Methods in Biology” ch.7.4