From 81efa3bc2a8d1d2c6631004ac8b3c217f4adfa26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Haraldson=20H=C3=B8ie?= <39849954+Magnushhoie@users.noreply.github.com> Date: Tue, 18 Oct 2022 01:02:49 +0100 Subject: [PATCH 1/4] Add paired t-test greater and less than options --- statannotations/stats/StatTest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/statannotations/stats/StatTest.py b/statannotations/stats/StatTest.py index b1a4bab..5f4ee28 100644 --- a/statannotations/stats/StatTest.py +++ b/statannotations/stats/StatTest.py @@ -111,6 +111,14 @@ def short_name(self): 't-test_ind': StatTest(stats.ttest_ind, 't-test independent samples', 't-test_ind', 't'), + + '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"), 't-test_welch': StatTest(stats.ttest_ind, 'Welch\'s t-test independent samples', From 4c8730b69413c7e5c313c8e4acbfd94d7c8e5d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Haraldson=20H=C3=B8ie?= <39849954+Magnushhoie@users.noreply.github.com> Date: Tue, 18 Oct 2022 01:05:03 +0100 Subject: [PATCH 2/4] Add paired t-test greater and less than options --- statannotations/stats/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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'] From 9efa8d611a48131f4e48bffbd2b99adcc6b9b21f Mon Sep 17 00:00:00 2001 From: Magnushhoie <39849954+Magnushhoie@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:29:52 +0000 Subject: [PATCH 3/4] tests for t-test ind + paired paired gt lt --- statannotations/stats/StatTest.py | 16 ++++++++-------- tests/test_stattest.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/statannotations/stats/StatTest.py b/statannotations/stats/StatTest.py index 5f4ee28..95755f2 100644 --- a/statannotations/stats/StatTest.py +++ b/statannotations/stats/StatTest.py @@ -111,14 +111,6 @@ def short_name(self): 't-test_ind': StatTest(stats.ttest_ind, 't-test independent samples', 't-test_ind', 't'), - - '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"), 't-test_welch': StatTest(stats.ttest_ind, 'Welch\'s t-test independent samples', @@ -127,6 +119,14 @@ def short_name(self): 't-test_paired': StatTest(stats.ttest_rel, 't-test paired samples', 't-test_rel', 't'), + '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/tests/test_stattest.py b/tests/test_stattest.py index 876249e..b724d4c 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') + 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") From 0830658db1254acdd6d727fef44fcceee1bf6ef7 Mon Sep 17 00:00:00 2001 From: Magnushhoie <39849954+Magnushhoie@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:33:47 +0000 Subject: [PATCH 4/4] test ttest_rel specify two-sided --- statannotations/stats/StatTest.py | 3 ++- tests/test_stattest.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/statannotations/stats/StatTest.py b/statannotations/stats/StatTest.py index 95755f2..6941a43 100644 --- a/statannotations/stats/StatTest.py +++ b/statannotations/stats/StatTest.py @@ -117,7 +117,8 @@ 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', diff --git a/tests/test_stattest.py b/tests/test_stattest.py index b724d4c..cb90f18 100644 --- a/tests/test_stattest.py +++ b/tests/test_stattest.py @@ -45,7 +45,7 @@ def test_ttest_ind(self): self.assertEqual(res1.pvalue, res2.pvalue) def test_ttest_rel(self): - test = StatTest(stats.ttest_ind, 't-test paired samples', 't-test_rel', 't') + 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)