JuliaStats / HypothesisTests.jl

Hypothesis tests for Julia
Other
292 stars 87 forks source link

Add ddof to PowerDivergenceTest and ChisqTest to allow changes to degrees of freedom #288

Open sprague252 opened 1 year ago

sprague252 commented 1 year ago

Resolves #266

This change adds a new keyword parameter ddof to PowerDivergenceTest and ChisqTest allowing users to change the number of degrees of freedom used for calculating p-values. This works the same as the ddof parameter in scipy.stats.chisquare. See the documentation for that function at

https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chisquare.html.

The ddof value defaults to 0 (no changes to the degrees of freedom). A supplied value for ddof decreases the number of degrees of freedom by the value of ddof. This is important when the distribution probabilities are calculated using parameters from measured data (e.g., mean and sample standard deviation), reducing the number of degrees of freedom.

I updated the docstrings for PowerDivergenceTest and ChisqTest and added a test for ChisqTest with ddof=2 to test/power_divergence.jl. (It passes.)

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +3.70 :tada:

Comparison is base (e03407a) 90.04% compared to head (7bba907) 93.75%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #288 +/- ## ========================================== + Coverage 90.04% 93.75% +3.70% ========================================== Files 28 28 Lines 1467 1730 +263 ========================================== + Hits 1321 1622 +301 + Misses 146 108 -38 ``` | [Impacted Files](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/288?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | Coverage Δ | | |---|---|---| | [src/power\_divergence.jl](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/288?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3Bvd2VyX2RpdmVyZ2VuY2Uuamw=) | `98.48% <100.00%> (-0.91%)` | :arrow_down: | ... and [27 files with indirect coverage changes](https://codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/288/indirect-changes?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 in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.