-
Notifications
You must be signed in to change notification settings - Fork 40
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
posthoc_conover_friedman calculates incorrect p-values #63
Comments
Hello! Thank you! Let's try to investigate this one deeper. Could you please run the following R script and post your results here? library(PMCMRplus)
y <- matrix(c(
3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92,
23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45,
26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72,
32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23,
26.65), nrow=6, ncol=6,
dimnames=list(1:6, LETTERS[1:6])
)
frdAllPairsConoverTest(y, p.adjust.method = 'none') Here are my results (equal to scikit-posthocs output):
|
Also, if you look at PMCMRplus code for I assume that you are using the latest version of PMCMRplus. |
Hello Max! I'm not familiar with R and don't have the capability to run R scripts. However, I've manually verified the results by substituting values into the formulas as outlined by Conover in his book "Practical nonparametric Statistics" (3rd. Edition, Wiley, 1999; pages 369-371). I suspect parameter T2 might be critical in this regard. PMCMRplus code references Conover's original paper from 1978 which specifies T2 as follows: However, in PMCMRplus code (and also in scikit-posthocs), T2 is calculated as follows: PMCMRplus:
scikit-posthocs:
Indeed, the implementation is the same. In both codes, however, the second power is applied only to the parentheses ((m * k + 1) / 2) and is excluded from the summation while Conover applies the second power to the whole term inside the summation (which includes R and the terms with n,m,k). This is not equivalent. My results corresponded to Pohlert's documentation for PMCMR as shown in my bug report. Maybe Code has changed in PMCMRplus (I didn't check). If so, a bug may have occured with the change. I compared both Conover's publications (1979 and 1999) and although he gives slightly different formulas in those two publications, they give the same results. |
Interesting! Thank you! I need some time to look into it. If you have time, please report this in PMCMRplus repo as well |
Thank you. I have compared the codes for Conover's test in PMCMR and PMCMRplus, and I have noticed that the calculations for T2 are indeed different in the two codes. The correct formula, i.e. consistent with the references, is present in PMCMR. I have already reported this discrepancy in PMCMRplus. |
Thank you! |
Here is an email response from the author & maintainer of the PMCMRplus package confirming the bug:
|
It seems that the bug has already been fixed in PMCMRplus version 1.9.10. See the news below. Please note that the rdrr snippet for online running the R Code uses version 1.7.0 of the PMCMRplus package and, therefore, contains the bug. |
Thank you! Fixed in the latest release. |
Describe the bug
I have identified a discrepancy in the p-values produced by 'scikit_posthocs.posthoc_conover_friedman' when compared to the results obtained through manual calculation using the provided references ([1] Conover & Iman, 1979; [2] Conover, 1999). Upon closer examination of '_posthocs.py', I believe the issue lies in the formula implemented on line 731 (calculation of T2) which is inconsistent with the formula specified in references [1] and [2]:
Dataset
See the code below.
To Reproduce
The script yields in following p-values:
Expected behavior
Correct results (as I believe) for the testing data are reported on page 18 of "The Pairwise Multiple Comparison of Mean Ranks Package (PMCMR)" by Thorsten Pohlert (2016).
I have verified these results using the script below and independently through manual calculation. The verification process followed the methodology outlined in [2] Conover, 1999 (page 371). The validation shows significant discrepancies with p-values produced by scikit_posthocs.
This yields in following p-values:
These values are consistent with Pohlert's results.
System and package information (please complete the following information):
** Aditional context **
No p-value adjustment was used in the tested runs.
The text was updated successfully, but these errors were encountered: