maximtrp / scikit-posthocs

Multiple Pairwise Comparisons (Post Hoc) Tests in Python
https://scikit-posthocs.rtfd.io
MIT License
338 stars 40 forks source link

Friedman with Dunn's test #74

Closed davwul closed 3 weeks ago

davwul commented 3 weeks ago

Hello!

I've been working on using statistics in Python and move away from relying on GraphPad Prism. I had some difficulties replicating the Friedman test with Dunn's correction that I was using in Prism. [https://www.graphpad.com/guides/prism/latest/statistics/how_the_friedman_test_works.htm]

Two things:

1) when I used my data with 'scikit_posthocs.posthoc_dunn' I end up doing a Kruskal-Wallis Dunn's test, which I assume happens because the data is treated as independent while it is in fact dependent (repeated)? Am I supposed to do some data formating beforehand?

2) I tried using the different friedman posthoc tests for Blocked Replicated data (which I have). I ended up trying nemenyi, conover and siegel, and siegel was the test that was able to exacly replicate my Prism results.

Any ideas why this is the case? How do you perform a Friedman Dunn's test (bonferroni correction) using scikit_posthocs.posthoc_dunn and any thoughts on why scikit_posthocs.posthoc_siegel_friedman replicated my Prism results?

Here is modified version of my dataset:

Sample    1       2       3       4       5
0   S-101   0.020   0.110   0.130   0.090   0.210
1   S-102   0.150   0.220   0.130   0.160   0.160
2   S-103   0.002   0.040   0.070   0.018   0.002
3   S-104   0.002   0.230   0.100   0.050   0.010
4   S-105   0.002   0.050   0.040   0.002   0.002
5   S-106   0.002   0.080   0.060   0.002   0.070
6   S-107   0.002   0.130   0.030   0.070   0.020
7   S-108   0.002   0.030   0.015   0.060   0.002
8   S-109   0.030   0.230   0.320   0.140   0.090
9   S-110   0.002   0.090   0.140   0.070   0.060
10  S-111   0.002   0.002   0.200   0.002   0.030
11  S-112   0.020   0.280   0.570   0.320   0.140

David

maximtrp commented 3 weeks ago

scikit_posthocs.posthoc_dunn is not applicable in your case as it is indeed for independent data and should be done after Kruskal-Wallis test.

scikit_posthocs.posthoc_siegel_friedman is the test you are looking for. All tests that can be used with dependent data have _friedman postfixes. There are some discrepancies in the naming of these tests. From GraphPad's website:

Following Friedman's test, Prism can perform Dunn's post test. For details, see Applied Nonparametric Statistics by WW Daniel, published by PWS-Kent publishing company in 1990 or Nonparametric Statistics for Behavioral Sciences by S Siegel and NJ Castellan, 1988. The original reference is O.J. Dunn, Technometrics, 5:241-252, 1964. Note that some books and programs simply refer to this test as the post test following a Friedman test and don't give it an exact name.

So, this is not an issue.