forum.alglib.net
http://forum.alglib.net/

Wilcoxon test p-value different from R, help me!
http://forum.alglib.net/viewtopic.php?f=2&t=394
Page 1 of 1

Author:  bonetti [ Wed Jun 29, 2011 3:59 am ]
Post subject:  Wilcoxon test p-value different from R, help me!

Hello everyone,

I'm trying to use the wilcoxonsignedranktest in C++ but no success. In fact, it works but show incorrect values. Take a look in my test code:

Code:
double mean;
double variance;
double skewness;
double kurtosis;
double both, left, right;
real_1d_array x = "[1,2,3,4,5,6,7,8,9,10]";
samplemoments(x, mean, variance, skewness, kurtosis); //mean = 5.50
wilcoxonsignedranktest(x, 10, mean, both, left, right);


The both returns 0.999952818327035 for me.

I did the same in R and get:
Code:
> wilcox.test(1:10)

        Wilcoxon signed rank test

data:  1:10
V = 55, p-value = 0.001953
alternative hypothesis: true location is not equal to 0


Then 0.999952818327035 is different from 0.001953

Do you know where is the problem???

Thanks!

Author:  Doug Jenkins [ Wed Jun 29, 2011 4:49 am ]
Post subject:  Re: Wilcoxon test p-value different from R, help me!

For the Alglib function you had an assumed median of 5.5, but for R it was 55.

With an assumed mean of 55 Alglib returns 0.001954047 for "both tails".

Author:  bonetti [ Wed Jun 29, 2011 2:23 pm ]
Post subject:  Re: Wilcoxon test p-value different from R, help me!

Hi Doug,

It works perfectly now. I need to use mean = 0 in my case:
Code:
wilcoxonsignedranktest(x, 10, 0, both, left, right);


Thank you very much!

Daniel

Author:  Doug Jenkins [ Wed Jun 29, 2011 11:30 pm ]
Post subject:  Re: Wilcoxon test p-value different from R, help me!

Daniel - you might find the spreadsheet at the link below useful:

http://newtonexcelbach.wordpress.com/20 ... functions/

It has all the Alglib statistics functions from the VBA package implemented as Excel user defined functions. Note that the VBA version is still 2.6, so there may be differences and new functionality in the latest C++ version. Certainly the listed Alglib program modules are not applicable to the current version.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/