I am taking a statistical data science course that is taught using R, and I am trying to replicate all the practical things in Julia. As we are doing quite basic stuff, mostly everything has been quite straightforward and similar to R, but I have been having some problems with hypothesis testing.
The package I am using is HypothesisTests.jl.
- I don’t exactly understand the implementation of
ChisqTestin that package. I get that if I want the goodness-of-fit test I have to provide a vectorxandtheta0and that works as expected. But for the contingency table test, it seems to only acceptxas a matrix and notxandy(for exampleChisqTest([50,100,50], [50,100,50])) as it would seem from the docs (link). The error message shows that the closest candidates are
ChisqTest(::AbstractVector{T}, ::AbstractVector{T}, ::Tuple{UnitRange{T}, UnitRange{T}})
ChisqTest(::AbstractVector{T}, ::AbstractVector{T}, ::T)
I don’t really understand where these come from or what values I should use there. I tried ChisqTest([50,100,50], [50,100,50], (1:3,1:3)) and ChisqTest([50,100,50], [50,100,50], 3), but both give an error “ArgumentError: at least one entry must be positive”, which confuses me. So I guess the main question here is, what is the argument y for? I thought I could use it for a contingency table test with two vectors, but I might be wrong.
- There is
prop.test(link) for testing probabilities/proportions in R. RDocumentation doesn’t really explain what is the test behind it. Googling has led me to believe that it is a z-test for proportions, which, if I understand correctly, isn’t available in theHypothesisTests.jlpackage. For a simpler case of comparing two proportions, I tried making a vectors of ones and zeros with correct proportions and then applied a two-sample z-test, but that didn’t yield the same result, so I don’t think that is the correct workaround. The R version gives chisq value for the test and I triedChisqTestwith contingency table, which gave a much more similar p-value to the R function, but not the same, and as I’ve understood, that should not be the correct approach. Any suggestions on how to replicate the R’sprop.testin Julia would be appreciated.