Skip to content

Commit 501d70b

Browse files
Merge pull request #93 from juliangehring/barber-candes-#81
Fix Barber-Candes adjustemt if all p-values are < 0.5
2 parents ac27637 + 971a8a6 commit 501d70b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/pval-adjustment.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,12 @@ end
644644

645645
function adjust(pValues::PValues{T}, method::BarberCandes) where T<:AbstractFloat
646646
n = length(pValues)
647+
# special cases unlike other p-adjust methods
647648
if n <= 1
648-
return fill(1.0, size(pValues)) # unlike other p-adjust methods
649+
return fill(1.0, size(pValues))
650+
end
651+
if maximum(pValues) < 0.5
652+
return fill(1/n, size(pValues))
649653
end
650654

651655
sorted_indexes, original_order = reorder(pValues)

test/test-pval-adjustment.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ using Base.Test
141141
end
142142
end
143143

144+
@testset "BarberCandès: All p-values < 0.5 (#87)" begin
145+
for pv in ([0.05, 0.1, 0.3], [0.01, 0.17, 0.25, 0.37, 0.47])
146+
n = length(pv)
147+
@test isapprox( adjust(PValues(pv), BarberCandes()), fill(1/n, n) )
148+
end
149+
end
144150

145151
@testset "Step-up/down" begin
146152

0 commit comments

Comments
 (0)