Skip to content

Commit 98696de

Browse files
committed
Fix Barber-Candes adjustemt if all p-values are < 0.5
Fixes #81.
1 parent b758039 commit 98696de

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
@@ -228,8 +228,12 @@ end
228228

229229
function adjust(pValues::PValues{T}, method::BarberCandes) where T<:AbstractFloat
230230
n = length(pValues)
231+
# special cases unlike other p-adjust methods
231232
if n <= 1
232-
return fill(1.0, size(pValues)) # unlike other p-adjust methods
233+
return fill(1.0, size(pValues))
234+
end
235+
if maximum(pValues) < 0.5
236+
return fill(1/n, size(pValues))
233237
end
234238

235239
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)