JuliaStats / HypothesisTests.jl

Hypothesis tests for Julia
MIT License
295 stars 87 forks source link

Better docstring for VarianceTests #254

Open KronosTheLate opened 2 years ago

KronosTheLate commented 2 years ago

This applies to both Equal and Unequal, T and Z tests. E.g. EqualVarianceTTest.

I have added the third positional argument mu0, as well as it default value, in the docstring. I have also added a reference to VarianceTTest, because I does not hurt, and that was what I was looking for, so it would have been very helpful to me.

nalimilan commented 2 years ago

Thanks, but the meaning of the argument should be mentioned too, otherwise it's impossible to use.

KronosTheLate commented 2 years ago

Thanks, but the meaning of the argument should be mentioned too, otherwise it's impossible to use.

Good point. I have now changed all 4 docstrings to mention μ0, in a uniform and clear manner. Satisfied with my suggestion?

mschauer commented 2 years ago

I would separate model assumptions, e.g. equal variance from hypotheses (eq. equal mean.) Something like:

For samples from two populations perform a two sample t-test for the null-hypothesis that the means of the two populations differ by $μ_diff = E[Y] - E [X]$ under the assumption that both populations have equal, but unknown variances.

Can we also rename μ0 to μ_diff or Δμ?

KronosTheLate commented 2 years ago

I would separate model assumptions, e.g. equal variance from hypotheses (eq. equal mean.) Something like:

For samples from two populations perform a two sample t-test for the null-hypothesis that the means of the two populations differ by $μ_diff = E[Y] - E [X]$ under the assumption that both populations have equal, but unknown variances.

Can we also rename μ0 to μ_diff or Δμ?

I think that both you suggestions are great. Do you agree that $μ_diff = E[Y] - E [X]$ would be more readable as $μ_diff = mean(x) - mean(y)$? I think that it is understandable even if you don't know standard notation, and that since it is actual code, it is as clear as can be. Note that the data arguments are (x, y), and a quick test tells me that the point estimate is mean(x)-mean(y), so I have swapped the order.

On the matter of μ_diff ovsΔμ, I would personally think that Δμ looks the best. And since we are already using Unicode for mu, adding the delta should not do much harm.

Does μ0 occur in other places with the meaning "mean difference"? If so, this change should be enforced everywhere.

nalimilan commented 2 years ago

Yes the E[X] notation may be more appropriate.

μ0 is used as an argument to OneSampleTTest, but there it's really the mean, so using a different notation is justified. It's also used as the name of an (internal) field of some other tests, but again referring to a mean. So overall it doesn't seem you'd have to rename anything else.

KronosTheLate commented 2 years ago

So mu0 should become Deltamu (on phone, no unicode). If you see this comment, please vote yes or no by comment and reason, so that the potential rename is a real concensus.

codecov-commenter commented 2 years ago

Codecov Report

Base: 92.93% // Head: 93.67% // Increases project coverage by +0.74% :tada:

Coverage data is based on head (a8af75d) compared to base (992fe20). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #254 +/- ## ========================================== + Coverage 92.93% 93.67% +0.74% ========================================== Files 28 28 Lines 1641 1723 +82 ========================================== + Hits 1525 1614 +89 + Misses 116 109 -7 ``` | [Impacted Files](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | Coverage Δ | | |---|---|---| | [src/t.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3Quamw=) | `98.30% <100.00%> (ø)` | | | [src/z.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3ouamw=) | `98.00% <100.00%> (ø)` | | | [src/common.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2NvbW1vbi5qbA==) | `100.00% <0.00%> (ø)` | | | [src/correlation.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2NvcnJlbGF0aW9uLmps) | `100.00% <0.00%> (ø)` | | | [src/jarque\_bera.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2phcnF1ZV9iZXJhLmps) | `100.00% <0.00%> (ø)` | | | [src/kruskal\_wallis.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2tydXNrYWxfd2FsbGlzLmps) | `100.00% <0.00%> (ø)` | | | [src/wald\_wolfowitz.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3dhbGRfd29sZm93aXR6Lmps) | `100.00% <0.00%> (ø)` | | | [src/breusch\_godfrey.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2JyZXVzY2hfZ29kZnJleS5qbA==) | `100.00% <0.00%> (ø)` | | | [src/kolmogorov\_smirnov.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2tvbG1vZ29yb3Zfc21pcm5vdi5qbA==) | `95.77% <0.00%> (+0.06%)` | :arrow_up: | | [src/durbin\_watson.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2R1cmJpbl93YXRzb24uamw=) | `98.91% <0.00%> (+0.07%)` | :arrow_up: | | ... and [11 more](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/254/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

nalimilan commented 1 year ago

Maybe call the argument Δμ0, for consistency with the one-sample tests where μ0 is used to refer to "mean under H0"?

KronosTheLate commented 1 year ago

Sounds good by me. Are you okay with making the change?