Skip to content
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

Add paired t-test greater and less than comparisons #85

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion statannotations/stats/StatTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,16 @@ def short_name(self):
't-test_welch', 't', equal_var=False),

't-test_paired': StatTest(stats.ttest_rel,
't-test paired samples', 't-test_rel', 't'),
't-test paired samples', 't-test_rel', 't'
alternative="two-sided"),

't-test_paired-gt': StatTest(stats.ttest_rel,
't-test paired samples', 't-test_rel', 't',
alternative="greater"),

't-test_paired-ls': StatTest(stats.ttest_rel,
't-test paired samples', 't-test_rel', 't',
alternative="less"),

'Wilcoxon': StatTest(stats.wilcoxon,
'Wilcoxon test (paired samples)', 'Wilcoxon'),
Expand Down
3 changes: 2 additions & 1 deletion statannotations/stats/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from statannotations.stats.StatResult import StatResult
from statannotations.stats.StatTest import StatTest

IMPLEMENTED_TESTS = ['t-test_ind', 't-test_welch', 't-test_paired',
IMPLEMENTED_TESTS = ['t-test_ind', 't-test_welch',
't-test_paired', 't-test_paired-gt', 't-test_paired-ls',
Comment on lines +10 to +11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IMPLEMENTED_TESTS = ['t-test_ind', 't-test_welch',
't-test_paired', 't-test_paired-gt', 't-test_paired-ls',
IMPLEMENTED_TESTS = ['t-test_ind', 't-test_welch',
't-test_paired', 't-test_paired-gt', 't-test_paired-ls',

'Mann-Whitney', 'Mann-Whitney-gt', 'Mann-Whitney-ls',
'Levene', 'Wilcoxon', 'Kruskal', 'Brunner-Munzel']

Expand Down
28 changes: 28 additions & 0 deletions tests/test_stattest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,34 @@ def test_short_name_exists(self):
test = StatTest.from_library("Mann-Whitney")
self.assertEqual("M.W.W.", test.short_name)

def test_ttest_ind(self):
test = StatTest(stats.ttest_ind, 't-test independent samples', 't-test_ind', 't')
res1 = test(self.x, self.y)
test2 = StatTest.from_library("t-test_ind")
res2 = test2(self.x, self.y)
self.assertEqual(res1.pvalue, res2.pvalue)

def test_ttest_rel(self):
test = StatTest(stats.ttest_ind, 't-test paired samples', 't-test_rel', 't', alternative="two-sided")
res1 = test(self.x, self.y)
test2 = StatTest.from_library("t-test_paired")
res2 = test2(self.x, self.y)
self.assertEqual(res1.pvalue, res2.pvalue)

def test_ttest_rel_ls(self):
test = StatTest(stats.ttest_rel, 't-test paired samples', 't-test_rel', 't', alternative="less")
res1 = test(self.x, self.y)
test2 = StatTest.from_library("t-test_paired-ls")
res2 = test2(self.x, self.y)
self.assertEqual(res1.pvalue, res2.pvalue)

def test_ttest_rel_gt(self):
test = StatTest(stats.ttest_rel, 't-test paired samples', 't-test_rel', 't', alternative="greater")
res1 = test(self.x, self.y)
test2 = StatTest.from_library("t-test_paired-gt")
res2 = test2(self.x, self.y)
self.assertEqual(res1.pvalue, res2.pvalue)

def test_wilcoxon_legacy_set_wilcox(self):
test = StatTest(wilcoxon, "Wilcoxon (legacy)", "Wilcox (L)")
res1 = test(self.x, self.y, zero_method="wilcox")
Expand Down