[ 
https://issues.apache.org/jira/browse/MATH-1233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146201#comment-18146201
 ] 

Alex Herbert commented on MATH-1233:
------------------------------------

This class is not in commons-math4. Functionality was moved to Commons 
Statistics.

This passes in Commons Statistics:
 
{code:java}
@Test
void testMath1233() {
    final WilcoxonSignedRankTest test = WilcoxonSignedRankTest.withDefaults();
    final double[] equal = {1, 2, 3};
    Assertions.assertThrows(IllegalArgumentException.class, () -> 
test.statistic(equal, equal));
    Assertions.assertThrows(IllegalArgumentException.class, () -> 
test.test(equal, equal));
    final double[] x = {1, 2, -3};
    final double[] y = {0, 0, 0};
    Assertions.assertEquals(3.0, test.statistic(x, y));
    Assertions.assertEquals(1.0, test.test(x, y).getPValue());
}
{code}
 
So all equals values is rejected as invalid rather then returning p=1.0.

The p-value calculation is as expected. it does not exceed 1.0. The code 
computes W+. The P-value is computed knowing that W- can be derived from the 
number of subjects n as `W- = n*(n+1)/2`. The larger magnitude W determines the 
P computation.

I suggest resolving as won't fix as the 3.6.1 branch support has ended.

> Uncommon wilcoxon signed-rank p-values
> --------------------------------------
>
>                 Key: MATH-1233
>                 URL: https://issues.apache.org/jira/browse/MATH-1233
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Icaro Cavalcante Dourado
>            Assignee: Rob Tompkins
>            Priority: Major
>             Fix For: 4.X
>
>         Attachments: MATH-1233-test.patch
>
>
> This implementation in WilcoxonSignedRankTest looks weird. For equal vectors, 
> the correct pValue should be 1, because it is the probability of the vectors 
> to come from same population.
> On the opposite, this implementation returns ~0 for equal vectors. So we need 
> to analyze the returned pValue > significanceLevel to reject H0 hypothesis, 
> while in R and many others tools we perform the opposite: pValue <= 
> significanceLevel gives us an argument to reject null hypothesis.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to