test_stat_function must be structured to take two vectors -- the first a combined sample vector and the second a logical vector indicating which sample each value came from, as well as a third and fourth value. i.e. (fun = function(jointvec,labelvec,val1,val2) ...). See examples.
Conversion Function
Test stat functions designed to work with the prior version of permutation_test_builder will not work.
E.g. If your test statistic is
mean_diff_stat = function(x,y,pow) abs(mean(x)-mean(y))^pow
then permutation_test_builder(mean_diff_stat,1) will no longer work as intended, but it will if you run the below code first.
perm_stat_helper = function(stat_fn,def_power) {
output = function(joint,vec_labels,power=def_power,na) {
a = joint[vec_labels]
b = joint[!vec_labels]
stat_fn(a,b,power)
}
output
}mean_diff_stat = perm_stat_helper(mean_diff_stat)