-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for exact tests #372
base: main
Are you sure you want to change the base?
Conversation
Support for exact tests, including fisher exact, barnard exact and boschloo_exact
Hi @ytzfhqs Thanks for opening the PR! Would you be able to provide some details/justification for adding this to Pingouin? I'm not in favor of adding them since the lower-level scipy functions are already pretty straightforward to use and well documented. |
I'm very happy to receive your reply. I wanted to add exact tests to pingouin for two main reasons:
Additionally, I have another question I wanted to ask. scipy's fisher_exact can only be used for 2x2 contingency tables. If my table looks like this:
How can I use fisher_exact to test if A, B, C have significant effects on the target variable? Could we provide a solution for this in pingouin? I noticed pingouin's chi2_independence uses Yates correction when expected frequencies are <5 - could we prompt the user to use exact tests instead, and provide API interfaces? Looking forward to your reply! |
Hi @ytzfhqs, Thanks for the details. Actually, most of the contingency functions implemented in Pingouin were written by @arthurpaulino, who might be able to chime in and answer your last question. I rarely use these functions so might not be the best person to answer. I understand your points and I think that we can add the Thanks, |
Oh it's been so long! Unfortunately, at this point, I have less context than @ytzfhqs ): |
Co-authored-by: Quentin Barthélemy <[email protected]>
@qbarthelemy That's a great idea, thank you very much for the suggestion, I will optimise my code! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ytzfhqs,
We should be good to merge once you've addressed the two minor comments below.
Thanks,
Raphael
|
||
stats = pd.DataFrame(stats)[["alternative", "odds ratio", "pval"]] | ||
|
||
return expected, observed, _postprocess_dataframe(stats) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add some simple unit tests in https://github.com/raphaelvallat/pingouin/blob/main/tests/test_contingency.py to verify that the function works as expected?
|
||
*Boschloo’s test is an exact test used in the analysis of contingency tables. | ||
It examines the association of two categorical variables, and is a uniformly | ||
more powerful alternative to Fisher’s exact test for 2x2 contingency tables.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add:
See also
--------
scipy.stats.fisher_exact, scipy.stats.barnard_exact, scipy.stats.boschloo_exact
method : string | ||
Methods of exact test. Options include``fisher``,``barnard``,``boschloo``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method : string | |
Methods of exact test. Options include``fisher``,``barnard``,``boschloo``. | |
method : {"fisher", "barnard", "boschloo"}, default="fisher" | |
Method of exact test. |
Support for exact tests, including fisher exact, barnard exact and boschloo exact