Skip to content

BUG: Fix unequal varcorrection in tukeyhsd - #9175

Closed
kuangzhexiang wants to merge 8 commits into
statsmodels:mainfrom
kuangzhexiang:feature/tukeyhsd_bugfix
Closed

kuangzhexiang wants to merge 8 commits into
statsmodels:mainfrom
kuangzhexiang:feature/tukeyhsd_bugfix

Conversation

@kuangzhexiang

@kuangzhexiang kuangzhexiang commented Mar 22, 2024 •

Copy link
Copy Markdown
Contributor
  • tests added / passed.
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.
Details

like tests in try_tukey_hsd.py
With the first dataset, results should be the same, as below.

image

@josef-pkt

Copy link
Copy Markdown
Member

Great, thanks for finding this mistake.

Do you have an example that uses this code path?
I don't remember now where this is used, and it does not have unit test coverage

@pep8speaks

pep8speaks commented Mar 25, 2024 •

Copy link
Copy Markdown

Hello @kuangzhexiang! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-04-07 02:49:39 UTC

@kuangzhexiang

Copy link
Copy Markdown
Contributor Author

Great, thanks for finding this mistake.

Do you have an example that uses this code path? I don't remember now where this is used, and it does not have unit test coverage

add a unit test in examples/try_tukey_hsd.py, is it ok?

@josef-pkt

Copy link
Copy Markdown
Member

No, unit tests need to go into a module that starts with tests

The most appropriate test file for Games-Howell unit test is "statsmodels\statsmodels\stats\tests\test_pairwise.py"

Also, the unit test need to go into a function with name starting with "test", see the other cases

The example files like examples/try_tukey_hsd.py were experimental and illustrative script files before the use of notebooks. We do not add those anymore.
Full examples go into docs notebooks.

If Games-Howell test verifies now against R, then we can add it to the official docs. I will look at that at the end of this PR.

If I understand correctly, then related PR and issue are #7332 and #8396

@kuangzhexiang

Copy link
Copy Markdown
Contributor Author

No, unit tests need to go into a module that starts with tests

The most appropriate test file for Games-Howell unit test is "statsmodels\statsmodels\stats\tests\test_pairwise.py"

Also, the unit test need to go into a function with name starting with "test", see the other cases

The example files like examples/try_tukey_hsd.py were experimental and illustrative script files before the use of notebooks. We do not add those anymore. Full examples go into docs notebooks.

If Games-Howell test verifies now against R, then we can add it to the official docs. I will look at that at the end of this PR.

If I understand correctly, then related PR and issue are #7332 and #8396

thanks a lot, added the unit test in test_pairwise.py

@kuangzhexiang

kuangzhexiang commented May 15, 2024 •

Copy link
Copy Markdown
Contributor Author

@josef-pkt Could you please review it? All checks have passed

@josef-pkt

Copy link
Copy Markdown
Member

Thanks

Looks good to me, but I want to go over some details in the related code.
I'm taking a break from robust and will go over it within a few days.

@josef-pkt josef-pkt mentioned this pull request Jun 17, 2024
6 tasks
@josef-pkt

Copy link
Copy Markdown
Member

many packages seems to have games-howell, tamhane t2 and dunnet t3 as options for unequal nobs/variance.

need future proof keywords when we add the other two.

Also, we eventually need an option to use standard p-value correction method, instead of hardcoded tukey hsd p-value distribution.

@josef-pkt

Copy link
Copy Markdown
Member

PMCMRplus gives the same results for p-values but with more digits

> res = gamesHowellTest(d[4:29,]$StressReduction, as.factor(d[4:29,]$Treatment))
> summary(res)

        Pairwise comparisons using Games-Howell test

data: d[4:29, ]$StressReduction and as.factor(d[4:29, ]$Treatment)
alternative hypothesis: two.sided
P value adjustment method: none
H0
                        q value         Pr(>|q|)    
mental - medical == 0     7.859 0.00019641028219 ***
physical - medical == 0   2.536 0.20585647592932    
physical - mental == 0   -2.979 0.12691156834160    
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

@josef-pkt josef-pkt added the superseded Used for PRs with content that is superseded by a newer PR label Jan 25, 2025
@josef-pkt

Copy link
Copy Markdown
Member

@kuangzhexiang Thanks again for the PR

merged in #9487
The main addition was to fix the plot_simultaneous method in the unequal var case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-stats prio-high superseded Used for PRs with content that is superseded by a newer PR type-bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants