Skip to content

Commit

Permalink
Merge pull request #249 from JuliaStats/dw/fisher_bracket
Browse files Browse the repository at this point in the history
Fix incorrect bracket and type instability in FisherExactTest
  • Loading branch information
mschauer committed Nov 4, 2021
2 parents dd35ae0 + 64abbe5 commit 5207b91
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "HypothesisTests"
uuid = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
version = "0.10.4"
version = "0.10.5"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
9 changes: 6 additions & 3 deletions src/fisher.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,15 @@ function StatsBase.confint(x::FisherExactTest; level::Float64=0.95, tail=:both,
if (x.a == maximum(dist(1.0)))
(0.0, Inf)
else
(0.0, fzero(obj, find_brackets(obj)...))
lower, upper = find_brackets(obj)
(0.0, lower == upper ? lower : find_zero(obj, (lower, upper)))
end
elseif tail == :right # lower bound
if (x.a == minimum(dist(1.0)))
(0.0, Inf)
else
(fzero(obj, find_brackets(obj)...), Inf)
lower, upper = find_brackets(obj)
(lower == upper ? lower : find_zero(obj, (lower, upper)), Inf)
end
elseif tail == :both
if method == :central
Expand Down Expand Up @@ -251,6 +253,7 @@ function cond_mle_odds_ratio(a::Int, b::Int, c::Int, d::Int)
Inf
else
obj(ω) = mean(dist(ω))-a
fzero(obj, find_brackets(obj)...)
lower, upper = find_brackets(obj)
lower == upper ? lower : find_zero(obj, (lower, upper))
end
end
2 changes: 1 addition & 1 deletion test/fisher.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using HypothesisTests, Test
using HypothesisTests: default_tail

@testset "Fisher" begin
t = HypothesisTests.FisherExactTest(1, 1, 1, 1)
t = @inferred(HypothesisTests.FisherExactTest(1, 1, 1, 1))
@test t.ω 1.0
@test pvalue(t; tail=:left) 0.8333333333333337
@test pvalue(t; tail=:right) 0.8333333333333337
Expand Down

2 comments on commit 5207b91

@devmotion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/48141

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.5 -m "<description of version>" 5207b91a281d461533828505858dfffd4ad15175
git push origin v0.10.5

Please sign in to comment.