Repository navigation
BUG/ENH: Tukeyhsd, fix unused variance, add Games-Howell - #9487
Conversation
|
old pattern: and does not include result from individual tests like degrees of freedom or test statistics. the above default correction is "bonf" bonf has the largest corrected p-values, holm the smallest, Games-Howell is in between |
|
we can also use fdr |
|
I guess we don't need to include any cleanup and refactoring in this PR. We need quite a bit of extra work in multicomp, e.g. #4379, which is not directly related to the main points of this PR. |
|
TukeyHSDResults is missing a return as pandas DataFrame as extra: we could add option for additional standard p-value correction, if we had uncorrected pvalues or test statistics. naming convention ? |
|
something is strange (wrong, unclear) Tukey results include attributes with use_var="unequal": However, unit test for games-howell passes the difference in var is factor 2, sqrt(2) for std_pairs sqrt(2 in last paragraph in section That's a pain, misleading name, definition for std_pairs tukey_hsd function divides var by 2: but then return the std for studentized range in std_pairs, instead of the std of the mean_diff TukeyHSDResult docstring incorrectly says: there are no unit tests for attributes like std_pairs in test_pairwise To clarify: This is equivalent to computing rectangular area of multivariate-t defined by t-statistic of mean diff at each pair. |
|
and another one tukey results has attribute no docs, no informative name, looks internal |
|
Problem with confidence interval plot, looks like a bug simultaneous ci uses q_crit which is
current example and unit test has 3 levels. What q_crit should we use in Games-Howell?
In any of the cases, the result will not match up directly with the Games-Howell results. Maybe easiest to justify is use tukey-hsd df_total with group specific variance. Another possible problem: Correction: It looks like it might do the correct computation even if variance is vector. todo: Aside: |
|
and currently there are no multiple testing corrected pairwise confidence intervals. and Currently significance level alpha is fixed from the beginning, i.e. when calling tukey_hsd method of wrapper function. The standard pattern in most other hypothesis test functions is to provide alpha at the end, e.g. as keyword for conf_int. If we delay computing q_crit until we need it in the results instance, there would not be a reason to specify alpha, We would also need to delay rejection decisions and base those on pvalues instead of critical values. Main reason for now is what to do with q_crit inclusion in returns and attributes. (That's too much refactoring for now, and needs design decisions. ) Aside: TukeyHSDResults does not have the alpha information, no alpha attribute. |
|
For this PR, I only need to additionally fix ci_simultaneous using q_crit_hsd.
update wrong again The first arg of Creating the results instance does not free up the memory of data and intermediate arrays. |
|
aside: The unit test for simultaneous ci (last case in test file) uses the cylinder example. Additionally, there is a division by zero problem and nans in the results in unequal case but not in equal var case. What is the minimum on a group sample size? but problem is that both France and Sweden have zero within variance (endog is discrete in example) This implies that the variance of the mean diff between the two is also zero and we cannot compute a t-statistic. Tukey-hsd estimates the variance based on all groups and does not have the pairwise problem. |
|
Interesting example example dropping Sweden (to avoid nans) and increasing alpha from 0.01 to 0.05 strange implication of hsd |
|
new plot using unequal var looks much better, France has short interval including Sweden |
d5930c1 to
4a1e947
Compare
|
more fun larger sample roughly based on cylinder data The following illustrate the problem with the equal variance assumption in tukey-hsd With unequal variance, the non-US pairs have relatively low variance of the diff, confidence intervals are relatively short. I changed the mean of Germany a bit, so now both US and Germany are different from the remaining three countries based on games-howell. However, Tukey-hsd is not able to separate out Germany. opposite case: Oops, The halfwidths agree pretty well between hsd and unequal variance, in larger sample. So, the ci_simultaneous seem to be a correct approximation also in the case of the unequal var method. differences within group variance are sampling variation |
|
pandas summary frame example cylinders with small adjustment to avoid zero within group variance but summary table has numeric formatting that is faster to read |
|
group1 versus group2 again But the order of pairs does not look so nice if the first group column varies faster than the second column. The labeling and diff direction will be more important with one-sided alternative as in trend tests. Aside I still don't know what to do in this PR. update for now I use groupT and groupC as names for treatment minus control. |
807f5fd to
8b36084
Compare
|
about done here |
8b36084 to
0012a9d
Compare
|
What's missing here or in next PR are unit tests directly for the varcorrection_xxx functions. |
|
merging |






rebased version closes #9175
see also PR #7332 which has additional unit test and api with connecting_letters
currently only rebased with fixing merge conflicts,
no squashing of commits yet.