Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: Add post-hoc tests to AnovaRM results #9589

Open
Tiffanyccchen wants to merge 6 commits intostatsmodels:mainfrom
Tiffanyccchen:feature/anova-posthoc
Open

ENH: Add post-hoc tests to AnovaRM results #9589
Tiffanyccchen wants to merge 6 commits intostatsmodels:mainfrom
Tiffanyccchen:feature/anova-posthoc

Conversation

@Tiffanyccchen
Copy link

Adds pairwise_tukeyhsd and allpairtest methods to the AnovaResults class. This allows for direct post-hoc analysis following a repeated measures ANOVA, simplifying the user workflow.

This change also refactors the GroupsStats class out of the sandbox and into the central tools.grouputils module. The _check_data_balanced method in AnovaRM is updated to use this new utility.

Unit tests are added for the new post-hoc methods and for the refactored GroupsStats class to ensure correctness and reliability.

Details

Notes:

  • It is essential that you add a test when making code changes. Tests are not
    needed for doc changes.
  • When adding a new function, test values should usually be verified in another package (e.g., R/SAS/Stata).
  • When fixing a bug, you must add a test that would produce the bug in main and
    then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass flake8. If on Linux or OSX, you can
    verify you changes are well formatted by running
    git diff upstream/main -u -- "*.py" | flake8 --diff --isolated
    
    assuming flake8 is installed. This command is also available on Windows
    using the Windows System for Linux once flake8 is installed in the
    local Linux environment. While passing this test is not required, it is good practice and it help
    improve code quality in statsmodels.
  • Docstring additions must render correctly, including escapes and LaTeX.

Adds pairwise_tukeyhsd and �llpairtest methods to the AnovaResults
class. This allows for direct post-hoc analysis following a repeated
measures ANOVA, simplifying the user workflow.

This change also refactors the GroupsStats class out of the sandbox
and into the central 	ools.grouputils module. The _check_data_balanced
method in AnovaRM is updated to use this new utility.

Unit tests are added for the new post-hoc methods and for the refactored
GroupsStats class to ensure correctness and reliability.
@Tiffanyccchen Tiffanyccchen changed the title ENH: Add post-hoc tests to AnovaRM results #9491 ENH: Add post-hoc tests to AnovaRM results Jul 4, 2025
@Tiffanyccchen Tiffanyccchen force-pushed the feature/anova-posthoc branch from 646e7ac to d3734b0 Compare July 5, 2025 04:10
@josef-pkt
Copy link
Member

josef-pkt commented Jul 17, 2025

Thanks for the PR

This will take some time to review.
One part moves groupstats out of sandbox multicomp.

The test case is for AnovaRM and not for plain anova. However, the connection to multicomp is in anova_lm, AFAICS.
I don't remember looking at multiple comparisons after repeated measures anova. The main case that I looked at was for oneway which is the basic case for tukey-hsd and now games-howell.

Another issue is that, AFAIR, the return of allpairstest method is outdated and should be improved to follow more recent patterns. (mentioned in issue ????)

update
944e8ba
changes the required results for a unit test which is not visible in the final change set.
Based on a brief look, I don't see what the reason and impact for backwards compatibility are.

@josef-pkt
Copy link
Member

too many changes unrelated to the main change
and the return of allpairs_test needs to be refactored before we add it to more public classes, places.

(I did not check what this does for RM anova)

refactoring the original code in the sandbox and moving it out requires more review and refactoring, and should be a separate PR.
#8396 #9489 and other issues AFAIR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants