Skip to content

Commit

Permalink
test failed due to 1/(nPerm+1) fix
Browse files Browse the repository at this point in the history
  • Loading branch information
behinger committed May 25, 2022
1 parent 255fc68 commit ef4b45c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/permutation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ isdefined(@__MODULE__, :io) || const io = IOBuffer()
end

@testset "permutationtest" begin
# the total area above and below the observed value should equal 1
# the total area above and below the observed value should be slightly greater than 1
# Why slightly greater? because we use the approximation to include the actual datapoint
# so that a p-value can never be p==0 but at most p == 1/(nperm+1)
@test all(map(sum,
zip(permutationtest(perm, m1, type=:lesser),
permutationtest(perm, m1, type=:greater))) .== 1)
permutationtest(perm, m1, type=:greater))) . (1+1/1001))

# we should have a p-value near 1 since our null distribution
# we should have a p-value > 0.05 since our null distribution
# was generated from value being tested...
@test first(permutationtest(perm, m1)) > 0.95
@test first(permutationtest(perm, m1)) > 0.05
# we should have a p-value near 0 since this effect is clear
@test last(permutationtest(perm, m1)) <= 1 / 1000
@test_throws ArgumentError permutationtest(perm, m1, type=:bad)
Expand Down

0 comments on commit ef4b45c

Please sign in to comment.