diff --git a/statannotations/stats/StatTest.py b/statannotations/stats/StatTest.py index b1a4bab..6941a43 100644 --- a/statannotations/stats/StatTest.py +++ b/statannotations/stats/StatTest.py @@ -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'), diff --git a/statannotations/stats/test.py b/statannotations/stats/test.py index e03ffbe..3052253 100644 --- a/statannotations/stats/test.py +++ b/statannotations/stats/test.py @@ -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', 'Mann-Whitney', 'Mann-Whitney-gt', 'Mann-Whitney-ls', 'Levene', 'Wilcoxon', 'Kruskal', 'Brunner-Munzel'] diff --git a/tests/test_stattest.py b/tests/test_stattest.py index 876249e..cb90f18 100644 --- a/tests/test_stattest.py +++ b/tests/test_stattest.py @@ -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")