Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FisherExactTest confint "ERROR: LoadError: ArgumentError: The interval [a,b] is not a bracketing interval." #122

Open
funnell opened this issue Dec 3, 2017 · 1 comment

Comments

@funnell
Copy link

funnell commented Dec 3, 2017

I'm calling FisherExactTests like so:

FisherExactTest(4, 362, 69, 125)

and get the following output:

Fisher's exact test                                                                                                                                  [23/1027]
-------------------
Population details:
    parameter of interest:   Odds ratio
    value under h_0:         1.0
    point estimate:          0.020160266511401688
Error showing value of type HypothesisTests.FisherExactTest:
ERROR: ArgumentError: The interval [a,b] is not a bracketing interval.
You need f(a) and f(b) to have different signs (f(a) * f(b) < 0).
Consider a different bracket or try fzero(f, c) with an initial guess c.

Stacktrace:
 [1] bisection64(::HypothesisTests.#obj#34{Symbol,HypothesisTests.FisherExactTest,Float64,HypothesisTests.#dist#33{HypothesisTests.FisherExactTest}}, ::Float6
4, ::Float64) at /home/tfunnell/.julia/v0.6/Roots/src/bracketing.jl:93
 [2] #find_zero#16(::Bool, ::Array{Any,1}, ::Function, ::HypothesisTests.#obj#34{Symbol,HypothesisTests.FisherExactTest,Float64,HypothesisTests.#dist#33{Hypot
hesisTests.FisherExactTest}}, ::Array{Float64,1}, ::Roots.Bisection) at /home/tfunnell/.julia/v0.6/Roots/src/bracketing.jl:137
 [3] find_zero(::Function, ::Array{Float64,1}, ::Roots.Bisection) at /home/tfunnell/.julia/v0.6/Roots/src/bracketing.jl:132
 [4] #fzero#56(::Array{Any,1}, ::Function, ::Function, ::Float64, ::Float64) at /home/tfunnell/.julia/v0.6/Roots/src/Roots.jl:98
 [5] #confint#32(::Symbol, ::Symbol, ::Function, ::HypothesisTests.FisherExactTest, ::Float64) at /home/tfunnell/.julia/v0.6/HypothesisTests/src/fisher.jl:186
 [6] (::StatsBase.#kw##confint)(::Array{Any,1}, ::StatsBase.#confint, ::HypothesisTests.FisherExactTest, ::Float64) at ./<missing>:0                  [3/1027]
 [7] #confint#32(::Symbol, ::Symbol, ::Function, ::HypothesisTests.FisherExactTest, ::Float64) at /home/tfunnell/.julia/v0.6/HypothesisTests/src/fisher.jl:196
 [8] show(::IOContext{Base.Terminals.TTYTerminal}, ::HypothesisTests.FisherExactTest) at /home/tfunnell/.julia/v0.6/HypothesisTests/src/HypothesisTests.jl:114
 [9] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::HypothesisTests.FisherExactTest) at ./REPL.jl:122
 [10] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::HypothesisTests.FisherExactTest) at ./REPL.jl:125
 [11] display(::HypothesisTests.FisherExactTest) at ./multimedia.jl:194
 [12] eval(::Module, ::Any) at ./boot.jl:235
 [13] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [14] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [15] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646
@devmotion
Copy link
Member

I added print statements in

lower, upper = find_brackets(obj)
(0.0, lower == upper ? lower : find_zero(obj, (lower, upper)))
and
lower, upper = find_brackets(obj)
(lower == upper ? lower : find_zero(obj, (lower, upper)), Inf)
to show the bracketing intervals and the values of the objective function at these points. It seems the problem is that the objective function returns non-finite values:

julia> confint(FisherExactTest(4, 362, 69, 125))
(lower, upper) = (0.00390625, 1.0)
(obj(lower), obj(upper)) = (-0.015296310108992683, 0.975)
(lower, upper) = (1.0, 4.503599627370496e15)
(obj(lower), obj(upper)) = (-0.025000000000000022, NaN)
ERROR: ArgumentError: The interval [a,b] is not a bracketing interval.
You need f(a) and f(b) to have different signs (f(a) * f(b) < 0).
Consider a different bracket or try fzero(f, c) with an initial guess c.

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants