The documentation provides the example:
pvalue(test::HypothesisTest; tail = :both)
but how do I enter this ie.
using HypothesisTests
pvalue(pvalue(ApproximateTwoSampleKSTest(x,y); :both)
isn’t accepted, so how do i put in that I want a two tailed sample? Unless I want the left or right tail.
The documented function signature is telling you that :both
is the default value for the tail
keyword argument, so if you don’t supply an alternative value, you will be getting the two-tailed p-value:
julia> using HypothesisTests
julia> x = randn(100_000); y = randn(100_000);
julia> pvalue(ApproximateTwoSampleKSTest(x, y))
0.4162728684426016
julia> pvalue(ApproximateTwoSampleKSTest(x, y); tail = :both)
0.4162728684426016
julia> pvalue(ApproximateTwoSampleKSTest(x, y); tail = :left)
0.49284527402027806
julia> pvalue(ApproximateTwoSampleKSTest(x, y); tail = :right)
0.21008354374916968
As an aside, I think I’ve mentioned it before but to reiterate it would be really good if you could copy/paste your own MWE into a fresh Julia session and run it before you post, to ensure that it actually reproduces the error you’re seeing. What you posted above doesn’t run as you’re missing a parenthesis at the end. Also note that when supplying keyword arguments you need to name them, i.e. tail = :both
rather than just :both
6 Likes
begin
Pkg.add("HypothesisTests")
using HypothesisTests
end
pvalue(ApproximateTwoSampleKSTest(x, y))
MethodError: no method matching pvalue(::HypothesisTests.ApproximateTwoSampleKSTest)
Closest candidates are:
pvalue(!Matched::HypothesisTests.ApproximateOneSampleKSTest; tail) at /home/brett/Documents/BEST.jl#==#0979e6f0-e5f0-4c29-8b3b-cc2ef56a2241:1
- top-level scope @ Local: 1 [inlined]
pvalue(ApproximateTwoSampleKSTest(x, y); tail = :both
MethodError: no method matching pvalue(::HypothesisTests.ApproximateTwoSampleKSTest; tail=:both)
Closest candidates are:
pvalue(!Matched::HypothesisTests.ApproximateOneSampleKSTest; tail) at /home/brett/Documents/BEST.jl#==#0979e6f0-e5f0-4c29-8b3b-cc2ef56a2241:1
- top-level scope @ Local: 1 [inlined]
pvalue(ApproximateTwoSampleKSTest(x, y); tail = :left)
MethodError: no method matching pvalue(::HypothesisTests.ApproximateTwoSampleKSTest; tail=:both)
Closest candidates are:
pvalue(!Matched::HypothesisTests.ApproximateOneSampleKSTest; tail) at /home/brett/Documents/BEST.jl#==#0979e6f0-e5f0-4c29-8b3b-cc2ef56a2241:1
- top-level scope @ Local: 1 [inlined]
pvalue(ApproximateTwoSampleKSTest(x, y); tail = :left)
MethodError: no method matching pvalue(::HypothesisTests.ApproximateTwoSampleKSTest; tail=:right)
Closest candidates are:
pvalue(!Matched::HypothesisTests.ApproximateOneSampleKSTest; tail) at /home/brett/Documents/BEST.jl#==#0979e6f0-e5f0-4c29-8b3b-cc2ef56a2241:1
top-level scope@Local: 1[inlined]
Does it matter that I’m using Pluto? how do i ensure I’m adding the latest version of packages in Pluto?
It
has
been said before, this is
to read.
5 Likes
I figured out that there was a conflict with other packages. There is also a problem that Pluto cuts stuff off.
Additionally, in your initial example, the code attempts to compute a p-value of a p-value, which of course, would be invalid.
Can I again suggest that for any problem you have, you try running the code in a fresh REPL session (NOT Pluto) to isolate where the issue comes from - from many of your posts I get the impression that the majority of your issues comes from incorrect usage of Pluto, rather than from the packages you’re using.
IJulia might also be a good alternative as it’s behaviour is pretty much like the plain REPL.
2 Likes
Yes, please do your homework before posting here @brett_knoss. We have all kinds of members in the forum with all levels of expertise willing to help. However, if you start to just dump any error you get here, people will treat it as SPAM.
5 Likes
Ok, I’ll try to test things more carefully. I’m having trouble using the HypothesisTests.jl tutorial, because it doesn’t provide examples with working variables. Other tutorials would benefit from this as well. I think this is one of the goals of Pluto, with sample notebooks.
2 Likes