Example: Kaplan Meier Empirical CDF

This example illustrates the K-M procedure. Assume 20 units are on life test and 6 failures occur at the following times: 10, 32, 56, 98, 122, and 181 hours. There were 4 working units removed from the test for other experiments at the following times: 50, 100, 125, and 150 hours. The remaining 10 working units were removed from the test at 200 hours. The K-M estimates for this life test are:

R(10) = 19/20
R(32) = 19/20 x 18/19
R(56) = 19/20 x 18/19 x 16/17
R(98) = 19/20 x 18/19 x 16/17 x 15/16
R(122) = 19/20 x 18/19 x 16/17 x 15/16 x 13/14
R(181) = 19/20 x 18/19 x 16/17 x 15/16 x 13/14 x 10/11


import com.imsl.stat.*;
import com.imsl.math.*;

public class KaplanMeierECDFEx1 {

    public static void main(String args[]) {
        double y[] = {10.0, 32.0, 56.0, 98.0, 122.0, 181.0, 50.0,
            100.0, 125.0, 150.0, 200.0};
        int freq[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10};
        int censor[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1};

        KaplanMeierECDF km = new KaplanMeierECDF(y);
        km.setFrequency(freq);
        km.setCensor(censor);
        double[] fx = km.evaluateCDF();

        int ntimes = km.getNumberOfPoints();
        System.out.println("Number of points = " + ntimes);

        double[] x = km.getTimes();
        PrintMatrix p = new PrintMatrix("CDF = 1 - survival of life test subjects");
        p.print(fx);
        p.setTitle("Times of change in CDF");
        p.print(x);
    }
}

Output

Number of points = 6
CDF = 1 - survival of life test subjects
     0    
0  0.05   
1  0.1    
2  0.153  
3  0.206  
4  0.263  
5  0.33   

Times of change in CDF
    0   
0   10  
1   32  
2   56  
3   98  
4  122  
5  181  

Link to Java source.