Repository navigation
Calculate adjusted p-values for Tukey HSD Test - #5418
AndrewDDavis wants to merge 6 commits into
Conversation
AndrewDDavis
commented
Dec 11, 2018
- calculate adjusted p-values when using the tukeyhsd function
- add the p-vals to the results table and as an attribute of the TukeyHSDResults object
…lts table and as an attribute of the TukeyHSDResults object
| return qsturng(1-alpha, k, df) | ||
|
|
||
|
|
||
| def get_tukeyPval(k, df, q): |
There was a problem hiding this comment.
pep-8 names (no capital letters and no camel case in function names)
e.g. get_tukey_pvalue
| std_pairs : standard deviation of pairwise mean differences | ||
| q_crit : critical value of studentized range statistic at given alpha | ||
| halfwidths : half widths of simultaneous confidence interval | ||
| p_adjs : adjusted p-values |
There was a problem hiding this comment.
name: p_adjs -> pvalues
pvalues should be spelled out instead of just one letter p.
I think, given that the function or class has already TukeyHSD in the name, we don't need to add _adjusted to the name.
|
Looks good based on reading through it, but I need to go through the details to understand the code path that this takes. only comment so far is to make names more explicit and follow more python style @AndrewDDavis Thanks for this enhancement, it has waited for implementation for a long time. |
Codecov Report
@@ Coverage Diff @@
## master #5418 +/- ##
==========================================
+ Coverage 81.75% 81.76% +0.01%
==========================================
Files 569 569
Lines 89851 89856 +5
Branches 10022 10022
==========================================
+ Hits 73455 73473 +18
+ Misses 14126 14118 -8
+ Partials 2270 2265 -5
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #5418 +/- ##
==========================================
- Coverage 81.75% 81.72% -0.03%
==========================================
Files 569 569
Lines 89851 89851
Branches 10022 10022
==========================================
- Hits 73455 73431 -24
- Misses 14126 14150 +24
Partials 2270 2270
Continue to review full report at Codecov.
|
|
Thanks for taking a look, I made the requested changes. The camel case was in there because I was attempting to follow the convention of the function names above it, but I certainly prefer to follow pep-8 also. I took a crack at the test. The values diverge quite a bit for higher p-values, but are within 10^-4 on the smaller ones -- 0.113 being the highest of the values I arbitrarily considered "small". |
|
|
||
| # check p-values (divergence of high values is expected) | ||
| small_pvals_idx = [2, 5, 7, 9] | ||
| assert_almost_equal(res[small_pvals_idx, 3], myres[8][small_pvals_idx], decimal=4) |
There was a problem hiding this comment.
It's better to use assert_allclose because it gives more flexibility
assert_almost_equal is old code from before assert_allclose was added to numpy.testing.
(history: we have been using assert_allclose for new code, but are slow, i.e. no concentrated effort, to change the old asserts.)
|
I won't have time to substantially review this until after Christmas break (*). It looks good to me, but I'd better check the details. However, I scheduled it for 0.10 because I think it can be merged fast and is a long requested improvement. (*) moving a family of five to a new house that isn't quite finished with the renovation yet. about the p-values: Numerical approximation to non-standard distributions often focus on the relevant range <= 0.1 (and >= 0.001), and are less careful in the larger range. So larger differences across packages in that range are not a surprise. |