JuliaStats / HypothesisTests.jl

Hypothesis tests for Julia
Other
292 stars 87 forks source link

Error computing p-value for KruskalWallisTest in Julia v1.6 #269

Closed jmejia8 closed 2 years ago

jmejia8 commented 2 years ago

The p-value cannot be computed in Julia >=1.6. It seems that Distributions.jl updated its API.

HypothesisTests v0.10.8:

julia> u5 = [620, 5350, 7220];

julia> u250 = [3580, 4180, 5690];

julia> u2500 = [3600, 3820, 3840, 3850, 4160, 5300, 6900, 7120, 9370];

julia> more = [3920, 4520, 4760, 8560, 10350];

julia> t = HypothesisTests.KruskalWallisTest(u5, u250, u2500, more);

julia> pvalue(t)
ERROR: MethodError: no method matching gamma_inc(::Float64, ::Float64)
Closest candidates are:
  gamma_inc(::Float64, ::Float64, ::Integer) at ~/.julia/packages/SpecialFunctions/LC8dm/src/gamma_inc.jl:839
  gamma_inc(::AbstractFloat, ::AbstractFloat, ::Integer) at ~/.julia/packages/SpecialFunctions/LC8dm/src/gamma_inc.jl:946
  gamma_inc(::Real, ::Real, ::Integer) at ~/.julia/packages/SpecialFunctions/LC8dm/src/gamma_inc.jl:944
Stacktrace:
 [1] gammaccdf
   @ ~/.julia/packages/StatsFuns/PAbJ9/src/distrs/gamma.jl:43 [inlined]
 [2] gammaccdf
   @ ~/.julia/packages/StatsFuns/PAbJ9/src/distrs/gamma.jl:45 [inlined]
 [3] chisqccdf
   @ ~/.julia/packages/StatsFuns/PAbJ9/src/distrs/chisq.jl:9 [inlined]
 [4] ccdf
   @ ~/.julia/packages/Distributions/9Albf/src/univariates.jl:624 [inlined]
 [5] pvalue(dist::Distributions.Chisq{Float64}, x::Float64; tail::Symbol)
   @ HypothesisTests ~/.julia/packages/HypothesisTests/vNU4p/src/HypothesisTests.jl:81
 [6] pvalue(x::KruskalWallisTest)
   @ HypothesisTests ~/.julia/packages/HypothesisTests/vNU4p/src/kruskal_wallis.jl:95
devmotion commented 2 years ago

I can't reproduce this error (I tried Julia 1.6.6 and 1.7.2).

I assume you might use an old version of SpecialFunctions that does not define gamma_inc(::Float64, ::Float64). This is not an issue with Distributions but with StatsFuns: https://github.com/JuliaStats/StatsFuns.jl/issues/136 It is fixed by https://github.com/JuliaStats/StatsFuns.jl/pull/138 which was just merged and will be available in a new release within the next hour.

Please reopen the issue if it persists even after updating your packages once the new StatsFuns version is available.