PowerAnalyses.jl icon indicating copy to clipboard operation
PowerAnalyses.jl copied to clipboard

ArgumentError when effect size is small (<=0.10)

Open jrenoux opened this issue 1 year ago • 0 comments

Hi,

I have been using this package to do some power analysis on tests with small effect sizes and when I put the effect size at 0.10 or lower, I get this error message:

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.

    [email protected]:52[inlined]
    var"#init_state#59"(::Float64, ::Float64, ::typeof(Roots.init_state), ::Roots.Bisection, ::Roots.Callable_Function{Val{1}, Val{false}, PowerAnalyses.var"#f#6"{Float64, Float64, Float64, PowerAnalyses.GoodnessOfFitChisqTest}, Nothing}, ::Float64, ::Float64, ::Float64, ::Float64)@bisection.jl:50
    init_state(::Roots.Bisection, ::Roots.Callable_Function{Val{1}, Val{false}, PowerAnalyses.var"#f#6"{Float64, Float64, Float64, PowerAnalyses.GoodnessOfFitChisqTest}, Nothing}, ::Float64, ::Float64, ::Float64, ::Float64)@bisection.jl:44
    [email protected]:6[inlined]
    var"#init#42"(::Nothing, ::Bool, ::Roots.NullTracks, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(CommonSolve.init), ::Roots.ZeroProblem{PowerAnalyses.var"#f#6"{Float64, Float64, Float64, PowerAnalyses.GoodnessOfFitChisqTest}, Tuple{Int64, Int64}}, ::Roots.Bisection, ::Nothing)@find_zero.jl:299
    #solve#46@find_zero.jl:491[inlined]
    var"#find_zero#39"(::Nothing, ::Bool, ::Roots.NullTracks, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Roots.find_zero), ::Function, ::Tuple{Int64, Int64}, ::Roots.Bisection, ::Nothing)@find_zero.jl:220
    find_zero@find_zero.jl:220[inlined]
    var"#find_zero#40"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Roots.find_zero), ::Function, ::Tuple{Int64, Int64})@find_zero.jl:243
    find_zero@find_zero.jl:243[inlined]
    #get_n#[email protected]:138[inlined]
    top-level scope@[Local: 6](http://localhost:1234/edit?id=d5a9cd82-ed71-11ed-3012-0b195a9fbaca#)[inlined]

Here is the code I use:

begin
	es = 0.10
	alpha = 0.05
	power = 0.80
	T = GoodnessOfFitChisqTest(3)
	get_n(T; alpha, power, es)
end

If I put es at 0.11 or higher, there is no error.

Thanks for the help!

jrenoux avatar May 08 '23 09:05 jrenoux