import javastat.survival.KaplanMeierEstimate;

 

/**

 *

 * <p>Example: class KaplanMeierEstimate.</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, 421, 329, 769, 365, 770, 1227, 268,

               475, 1129, 464, 1206, 638, 563, 1106, 431, 855, 803,

               115, 744, 477, 448, 353, 377};

double[] censor1 = {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[][] covariate1 = { {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 KaplanMeierEstimate(0.05, time1, censor1);

estimate1 = testclass1.estimate;

variance = testclass1.variance;

confidenceInterval = testclass1.confidenceInterval;

print("The estimate for the first observation (non-null constructor)" +

     "                         =  " + estimate1[0]);

print("The confidence interval corresponding to the first observation " +

     "(non-null constructor) = [" +

     confidenceInterval[0][0] + " , " + confidenceInterval[0][1] + "]");

 

testclass2 = new KaplanMeierEstimate();

confidenceInterval = testclass2.confidenceInterval(0.05, time1, censor1);

estimate1 = testclass2.estimate(time1, censor1);

variance = testclass2.variance(time1, censor1);

 

testclass3 = new KaplanMeierEstimate(time1, censor1, covariate1);

estimate3 = testclass3.estimate;

power = 1.0;

for (int i = 0; i < covariate1.length; i++)

{

        power *= Math.exp(covariate1[i][5] * testclass3.coefficients[i]);

}

estimate3Prop = Math.pow(estimate3[0], power);

print("The estimate for the first observation under proportional hazards " +

     "assumption                 =  " + estimate3Prop);

 

Results:

The estimate for the 1'th observation based on non-null constructor  = 0.885

The confidence interval corresponding to the 1'th observation based on non-null

constructor = [0.762 , 1.0]

The estimate for the first observation under proportional hazards assumption                 

= 0.952