import javastat.survival.regression.CoxRegression;
/**
*
* <p>Example: class CoxRegression.</p>
* <p>Data Source: Collett, D. (1994). Modelling
Survival Data in Medical
* Research.
*/
double[] time = {156, 1040, 59, 421, 329, 769, 365, 770, 1227, 268, 475,
1129, 464, 1206, 638, 563, 1106, 431, 855, 803, 115,
744, 477, 448, 353, 377};
double[] censor = {1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 0, 0, 1, 0};
double[][] covariate = { {1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1,
2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2},
{66, 38, 72, 53, 43, 59, 64, 57, 59, 74, 59,
53, 56, 44, 56, 55, 44, 50, 43, 39, 74, 50,
64, 56, 63, 58} };
testclass1
= new CoxRegression(0.05, time, censor, covariate);
coefficients = testclass1.coefficients;
variance = testclass1.variance;
testStatistic =
testclass1.testStatistic;
pValue = testclass1.pValue;
confidenceInterval =
testclass1.confidenceInterval;
print("The estimated coefficients (non-null constructor)
= [" +
coefficients[0] + " , " + coefficients[1] +
"]");
print("The p-values (non-null constructor)
=
[" +
pValue[0] + " , " + pValue[1] + "]");
testclass2
= new CoxRegression();
coefficients = testclass2.coefficients(time, censor, covariate);
testStatistic =
testclass2.testStatistic(time, censor, covariate);
pValue = testclass2.pValue(time, censor, covariate);
confidenceInterval =
testclass2.confidenceInterval(0.1, time,
censor, covariate);
print("The test statistics (null constructor)
= [" +
testStatistic[0]
+ " , " + testStatistic[1] +
"]");
print("The confidence interval for b1 (null constructor)
= [" +
confidenceInterval[0][0] + "
" + confidenceInterval[0][1] +
"]");
print("The confidence interval for b2 (null constructor)
= [" +
confidenceInterval[1][0] + "
" + confidenceInterval[1][1] +
"]");
Results:
The
estimated coefficients based on non-null constructor = [-0.796 ,
0.147]
The
p-values for the test based on non-null constructor = [0.209
, 0.0010]
The
test statistics based on null constructor
= [-1.258
3.196]
The confidence
interval for the first parameter based on null constructor
= [-1.837 , 0.245]
The confidence
interval for the second parameter based on null constructor
= [0.071
0.222]