Repository navigation
Conversation
…rval calculations. also allow user to provide desired group order for display (was driving me nuts). Responding to issue statsmodels#789 in master.
…es, adding initial hochberg calculations
…ib. is matplotlib a required package? issue statsmodels#789
…y machine and this commit is working correctly, at least for my test dataset
…hat consistent. Still dont love them. Basic testing proves this is functional. issue statsmodels#789
|
Thank you about the plots:
examples for this pattern are in statsmodels graphics, |
…lotlib internally imported, allowed attachemnt of ax argument, and returned associated fig instance.
…nts, and made comparison_name optional so you could just plot all groups in black without preference. for pull request statsmodels#809
…lways just calculated now. pull request statsmodels#809
|
Looks like the Travis build is failing in the |
|
The actual test methods are inherited from CheckTuckeyHSDMixin(object) In the methods, test_multicomptukey, test_group_tukey and test_shortcut_function, the double indexed results need to be replaced with the corresponding attributes of the new results class. |
|
The docstrings need to be converted to the numpy documentation standard https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt |
|
We also need to add unit tests for the new functionality, especially the confidence intervals. Tyler, can you get benchmark/ verified results for those for example for the datasets that are used in the unittests in the TestTuckeyHSD? |
|
Tyler, thanks again for working on this. I'm busy until the middle of next week, but I would like to get this merged later next week. Then, I can also look into any loose ends, and make any additional changes that will still be necessary. |
|
If we assume MATLAB results as the gold standard, I can certainly compute intervals on a couple datasets in Matlab and compare results against python, running them in If it's just converting res elements to |
|
If the definitions for the confidence intervals are pretty standard, then MATLAB will be good. In some other cases, we had to go over several other statistical packages to figure out what the different versions were doing (popular difference is in degrees of freedom corrections), and to decide what we support. |
|
Well, seeing as I essentially just translated the Matlab multcomp function into python, these had better be the same confidence intervals. I've done some personal confirmation of this on my own and everything checks out, but unittests are still wise. The math behind them comes from Hochberg et al. p94 (also in the docstring) if I need to be any more specific. Unfortunately, Matlab is the only place I have encountered these specific interval calculations, so I don't know of any alternative methods of confirmation. But I have complete faith in the Matlab implementation. |
|
Did you actually translate license incompatible matlab code for this? checking again: R has also confidence interval, and the tukeyhsd function has confidence intervals that are already tested against R (I'm just looking at bits and pieces, I don't have a full overview yet.) |
|
Ok. I feel as though I have not done a good job explaining this pull request. Let's go for the full overview. A little Matlab backgroundMatlab has an excellent package for multiple comparisons called What is unique about this plot is that the confidence interval for each mean is universal; each CI allows simultaneous visual comparison of significance to any other group mean. That is to say, if you look at the width of one group CI and it does not overlap with another, those two means will be found to be significantly different at the p=0.05 level using the tukey hsd test. Whereas in your initial blog example, you needed to plot a difference of means and its CI for each pair of groups (which would be 6 CIs for 4 groups, 10 for 5 groups and so on exponentially), this plot requires only a single CI for each group (4 CIs for 4 groups, 5 for 5 and so on) to visually identify the same information. It's quite nice once you get used to it. These CIs were first proposed by Hochberg et al. and are based off knowledge of the q_crit value from tukey's hsd and the RMSE of all group means. (And just to reiterate, these are NOT the same CIs as tukey confidence limits, R's confidence intervals, or even the CIs outputted by statsmodels's tukeyhsd().) On to PythonTo my knowledge, python has no such implementation of these "Hochberg" intervals. As far as I know, nor does Pandas or R. Seeing as I very much like this plot, and it's used a lot in my department for a quick way to compare all group means, I coded up this pull request to emulate the Hopefully this clears a few things up! I am happy to try and keep contributing. tl;dr: no, this code is not tranlsated (bad word choice on my part) from Matlab and no, the confidence intervals computed in my pull request are not the same as tukey range test CIs. |
|
Thank you for spelling this out very explicitly, I think I understand. And thanks for clarifying the "translation", it's not what we usually understand under translating code, and we need to be careful with license restricted or incompatible code. I didn't want to sound critical, I just needed some clarification. I think this pull request is a good improvement and enhancement. |
…ng passed into stats.tukeyhsd() instead of the list of independent group nobs. This meant that df_total and thus the crit_int interval widths were being calculated incorrectly. Matters for pull request statsmodels#809 so that now the interval widths of plot_intervals will match the results_table.
|
So I see the comment in tukeyhsd() that there's an error in the variance calculation when |
|
I don't remember the details for the comment. There are many combinations of whether nobs are scalar or vectors and whether vars are pooled and I don't remember for which case(s) it failed. (Also I don't remember whether that was supposed to work for the single sample case). About your change with tukeyhsd has several test cases against R, but I might not have paid attention whether there are unequal sample size cases. There should be some, but from a quick look at test_pairwise I cannot see that. We need to fix the tests and add new unit tests to confirm what works and whether something doesn't work correctly. |
|
usage of the plot functions (based on reading the code again, without playing with an example) current: Having two functions internally is fine to separate calculation code from pure plotting code (but not necessary). However I think it would be less confusing to have only one user-facing plot function, and make any other methods private (prefix with underline). AFAICS, we have to use cases calling plots:
Using qcrit as argument looks inconvenient to me, since the user needs to find qcrit (or is there a special use for it?) Allowing user to specify alpha instead to change it from the original call to tukeyhsd looks more convenient to me. suggestion: only one user facing method plot_interval(_hochberg)
naming of functions: I think we should also add the pairwise confidence interval plots (as in the other statistical packages) (maybe later) "interval" as qualifier looks a bit redundant in the name |
|
Good suggestions. You are correct that those two use cases were the ones I was anticipating. For 1), I agree that Organization of methods: Make Renaming methods: I went back over Hochberg's text real quick to see what he called these intervals - IMO, "hochberg" is meaningless to users. He calls them "simultaneous confidence intervals". One of |
|
just a note on TravisCI: it fails these days sometimes with setup network problems unrelated to our code. your suggestion are fine with me, I also thought about dropping alpha/qcrit, but don't have a strong preference.
I don't know if there would be any plots that don't plot confidence intervals (groupings, ...?), which would make adding
|
There was a problem hiding this comment.
the class docstring can have an Attributes section, where we can add the documentation for attributes that don't have their own docstring
same for MultiComparison (I can also add that later)
(partially duplicated comment because I made the other comment on the changeset instead of the pull request)
|
I think this looks pretty much ready to merge. |
|
@tylerhartley Do you still have any changes that you haven't pushed yet? I will try to rebase the changes in this pull request today, and then it won't be easy to get additional changes from this pull request. (except cherry-picking) |
|
No - this is the full working copy. I think adding some plotting functionality to allpairtests etc. might be fun, but it should probably be in a separate pull request. So this is ready on my end. |
|
Thank you Tyler. There are still many places that can be improved in this area of statsmodels. I just merged a pull request #784 with some cleanup changes for some tests in statsmodels.stats, but haven't touched results classes yet, nor plotting support. If you want to work directly related to this pull request, then you should wait until I have merged this, so you can get a master with the changes. I should manage to do the merge in the next few days. |
…lotlib internally imported, allowed attachemnt of ax argument, and returned associated fig instance.
…nts, and made comparison_name optional so you could just plot all groups in black without preference. for pull request statsmodels#809
…lways just calculated now. pull request statsmodels#809
…e for use in hochberg, remove rmseofgroup statsmodels#809
|
rebased version is in PR #849 |
|
@tylerhartley I merged the rebased branch, Thank you for working on this. |
…lotlib internally imported, allowed attachemnt of ax argument, and returned associated fig instance.
…nts, and made comparison_name optional so you could just plot all groups in black without preference. for pull request statsmodels#809
…lways just calculated now. pull request statsmodels#809
…e for use in hochberg, remove rmseofgroup statsmodels#809
Tyler tukeyhsd rebased closes statsmodels#789 closes statsmodels#824 closes statsmodels#809
In response to issue #789, created a results class
TukeyHSDResultsthat more concisely contains the output of a tukey honesty significant difference test from theMultiComparisonclass. This class now contains all the raw output that MultiComparison.tukeyhsd() used to, plus a couple extras. The Hochberg interval plotting i discussed is also contained within this new class, such that the expected workflow would be something like:The current workflow is also compatible with the
pairwise_tukeyfunction.