import javastat.survival.inference.WilcoxonTest;

 

/**

 *

 * <p>Example: class WilcoxonTest.</p>

 * <p>Data Source: Collett, D. (1994). Modelling Survival Data in

 *    Medical Research. New York: Chapman and Hall, pp. 290-291. </p>

 */

 

double[] time1 = {156, 1040, 59,  329, 268, 638, 1106, 431, 855, 803,

               115, 477, 448};

double[] time2 = {421, 769, 365, 770, 1227, 475, 1129, 464, 1206, 563,

               744, 353, 377};

double[] censor1 = {1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0};

double[] censor2 = {0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0};

 

testclass1 = new WilcoxonTest(time1, censor1, time2, censor2);

testStatistic = testclass1.testStatistic;

pValue = testclass1.pValue;

print("The Wilcoxon statistic (non-null constructor)    = " + testStatistic);

print("The p-value for the test (non-null constructor)   = " + pValue);

 

testclass2 = new WilcoxonTest();

testStatistic = testclass2.testStatistic(time1, censor1, time2, censor2);

pValue = testclass2.pValue(time1, censor1, time2, censor2);

print("The Wilcoxon statistic (null constructor)        = " + testStatistic);

print("The p-value for the test (null constructor)       = " + pValue);

 

Results:

The Wilcoxon statistic based on non-null constructor   = 47.0

The p-value for the test based on non-null constructor  = 0.166

The Wilcoxon statistic based on null constructor       = 47.0

The p-value for the test based on non-null constructor  = 0.166