HypothesisTests.jl
HypothesisTests.jl copied to clipboard
problem with Wilcoxon signed rank test
HypothesisTests v0.8.0, Julia 1.0.1 MacOS
- the package is working:
julia> SignedRankTest([0.228,-5.58,-2.04,-1.43,1.80,2.52,0.17,3.07,1.37,0.86,0.15,-3.36,0.14,0.23,-0.89])
Exact Wilcoxon signed rank test
-------------------------------
Population details:
parameter of interest: Location parameter (pseudomedian)
value under h_0: 0
point estimate: 0.17
95% confidence interval: (-1.465, 1.015)
Test summary:
outcome with 95% confidence: fail to reject h_0
two-sided p-value: 0.8469
Details:
number of observations: 15
Wilcoxon rank-sum statistic: 64.0
rank sums: [64.0, 56.0]
adjustment for ties: 0.0
- Except when it isn't:
julia> SignedRankTest([-0.228,-5.58,-2.04,-1.43,1.80,2.52,0.17,3.07,1.37,0.86,0.15,-3.36,0.14,0.23,-0.89])
p-values must be in [0.,1.]
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] Type at /Users/travisporco/.julia/packages/StatsBase/NzjNi/src/statmodels.jl:385 [inlined]
[3] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::ExactSignedRankTest{Float64}) at /Users/travisporco/.julia/packages/HypothesisTests/M3Ysg/src/HypothesisTests.jl:122
[4] show at ./sysimg.jl:194 [inlined]
[5] limitstringmime(::MIME{Symbol("text/plain")}, ::ExactSignedRankTest{Float64}) at /Users/travisporco/.julia/packages/IJulia/0cLgR/src/inline.jl:36
[6] display_mimestring(::MIME{Symbol("text/plain")}, ::ExactSignedRankTest{Float64}) at /Users/travisporco/.julia/packages/IJulia/0cLgR/src/execute_request.jl:73
[7] display_dict(::ExactSignedRankTest{Float64}) at /Users/travisporco/.julia/packages/IJulia/0cLgR/src/execute_request.jl:101
[8] #invokelatest#1 at ./essentials.jl:697 [inlined]
[9] invokelatest at ./essentials.jl:696 [inlined]
[10] execute_request(::ZMQ.Socket, ::IJulia.Msg) at /Users/travisporco/.julia/packages/IJulia/0cLgR/src/execute_request.jl:256
[11] #invokelatest#1 at ./essentials.jl:697 [inlined]
[12] invokelatest at ./essentials.jl:696 [inlined]
[13] eventloop(::ZMQ.Socket) at /Users/travisporco/.julia/packages/IJulia/0cLgR/src/eventloop.jl:8
[14] (::getfield(IJulia, Symbol("##12#15")))() at ./task.jl:259
- Correct answer to problem:
R> wilcox.test(c(-0.228,-5.58,-2.04,-1.43,1.80,2.52,0.17,3.07,1.37,0.86,0.15,-3.36,0.14,0.23,-0.89))
Wilcoxon signed rank test
data: c(-0.228, -5.58, -2.04, -1.43, 1.8, 2.52, 0.17, 3.07, 1.37, 0.86, 0.15, -3.36, 0.14, 0.23, -0.89)
V = 60, p-value = 1
alternative hypothesis: true location is not equal to 0
FWIW, the p-value is really out of the correct range:
julia> pvalue(SignedRankTest([-0.228,-5.58,-2.04,-1.43,1.80,2.52,0.17,3.07,1.37,0.86,0.15,-3.36,0.14,0.23,-0.89]))
1.0220336914062502
Wow, that is incredibly probable