Randomly shuffles all observations across groups while preserving group sample sizes, creating a new super sample under the null hypothesis of no group differences, and computes a specified statistic on the resulting permuted super sample.
Details
This function performs a permutation test by:
Extracting all data points from all groups
Randomly shuffling the data
Reassigning data to groups with the same sample sizes as the original
Computing the test statistic on the permuted data
This approach tests the null hypothesis that group labels are exchangeable, which is natural for testing whether sub-populations differ.