import javastat.survival.inference.LogRankTest;
/**
*
* <p>Example: class LogRankTest.</p>
* <p>Data Source: Collett, D. (1994). Modelling
Survival Data in Medical
* Research.
*/
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 LogRankTest(time1, censor1, time2, censor2);
testStatistic =
testclass1.testStatistic;
pValue = testclass1.pValue;
print("The log rank statistic (non-null constructor) = " + testStatistic);
print("The p-value for the test (non-null constructor) = " + pValue);
testclass2
= new LogRankTest();
testStatistic =
testclass2.testStatistic(time1, censor1, time2, censor2);
pValue = testclass2.pValue(time1, censor1, time2, censor2);
print("The log rank statistic (null constructor) =
" + testStatistic);
print("The p-value for the test (null constructor) = " + pValue);
Results:
The
log rank statistic based on non-null constructor = 1.766
The
p-value for the test based on non-null constructor = 0.303
The
log rank statistic based on null constructor = 1.766
The
p-value for the test based on non-null constructor = 0.303