Difference between revisions of "Survival Analysis Using Kaplan-Meier"

From SOCR
Jump to: navigation, search
m
m
Line 1: Line 1:
<nowiki><pre>
+
<verbatim>
 +
<pre>
 
/*
 
/*
  
Line 65: Line 66:
 
}
 
}
 
</pre>
 
</pre>
</nowiki>
+
</verbatim>
 +
 
  
 
{{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=Survival_Analysis_Using_Kaplan-Meier}}
 
{{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=Survival_Analysis_Using_Kaplan-Meier}}

Revision as of 10:47, 22 January 2007

<verbatim>

/*

January 2007. Annie Che <chea@stat.ucla.edu>. UCLA Statistics.

reference for example data and formula:
	Modern Applied Statistics with S. Fourth Edition
	by W. N. Venables and B. D. Ripley
	Note that the first method of hazard calculation is used here (see reference for details).
*/

package edu.ucla.stat.SOCR.analyses.example;

import java.util.HashMap;
import edu.ucla.stat.SOCR.analyses.data.Data;
import edu.ucla.stat.SOCR.analyses.data.DataType;
import edu.ucla.stat.SOCR.analyses.result.SurvivalResult;


public class SurvivalKaplanMeierExample {
	public static void main(String args[]) {

		double[] time = {1,10,22,7,3,32,12,23,8,22,17,6,2,16,11,34,8,32,12,25,2,11,5,20,4,19,15,6,8,17,23,35,5,6,11,13,4,9,1,6,8,10};
		byte[] censor = {1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,0};
		String[] treat = {"control","6-MP","control","6-MP","control","6-MP","control","6-MP",    "control","6-MP","control","6-MP","control","6-MP","control","6-MP","control","6-MP",   "control","6-MP","control","6-MP","control","6-MP","control","6-MP","control","6-MP",    "control","6-MP","control","6-MP","control","6-MP","control","6-MP","control","6-MP",    "control","6-MP","control","6-MP"};

		try {
			Data data = new Data();
			SurvivalResult result = (SurvivalResult)data.getSurvivalResult(time, censor, treat);
			double[][] survivalTimeArray = result.getSurvivalTime();
			double[][] survivalRateArray = result.getSurvivalRate();
			double[][] upperCIArray = result.getSurvivalUpperCI();
			double[][] lowerCIArray = result.getSurvivalLowerCI();
			int[][] atRiskArray = result.getSurvivalAtRisk();
			double[][] survivalSEArray = result.getSurvivalSE();
			String timeList = result.getSurvivalTimeList();;
			double[][] survivalTime = result.getSurvivalTime();
			double[][] survivalRate = result.getSurvivalRate();
			double[][] upperCI = result.getSurvivalUpperCI();;
			double[][] lowerCI = result.getSurvivalLowerCI();
			double[][] survivalSE = result.getSurvivalSE();
			double[][] censoredTime = result.getCensoredTimeArray();;
			double[][] censoredRate = result.getCensoredRateArray();
			double[] maxTime = result.getMaxTime();
			int[][]    atRisk = result.getSurvivalAtRisk();;
			String[]   groupNames = result.getSurvivalGroupNames();

			System.out.println("\n\nSURVIVAL TIME         = " + timeList);
			System.out.println("\n\nTIME | NUMBER_AT_RISK | RATE | STANDARD_ERROR_OF_RATE | UPPER_CI | LOWER_CI ");
			for (int i = 0; i < survivalRate.length; i++) {
				System.out.println("\n\nTREATMENT GROUP = " + groupNames[i]+"\n");
				for (int j = 0; j < survivalRate[i].length; j++) {
					if (upperCI[i][j] == 1) {
						System.out.println("\n" +  survivalTime[i][j] +"\t" + atRisk[i][j] + "\t" + survivalRate[i][j] +"\t" + survivalSE[i][j] + "\t" + upperCI[i][j]+"\t\t" + lowerCI[i][j]);
					} else {
						System.out.println("\n" +  survivalTime[i][j] +"\t" + atRisk[i][j] + "\t" + survivalRate[i][j] +"\t" + survivalSE[i][j] + "\t" + upperCI[i][j]+"\t" + lowerCI[i][j]);
					}
				}
			}

		} catch (Exception e) {
			System.out.println(e);
		}
	}
}

</verbatim>




Translate this page:

(default)
Uk flag.gif

Deutsch
De flag.gif

Español
Es flag.gif

Français
Fr flag.gif

Italiano
It flag.gif

Português
Pt flag.gif

日本語
Jp flag.gif

България
Bg flag.gif

الامارات العربية المتحدة
Ae flag.gif

Suomi
Fi flag.gif

इस भाषा में
In flag.gif

Norge
No flag.png

한국어
Kr flag.gif

中文
Cn flag.gif

繁体中文
Cn flag.gif

Русский
Ru flag.gif

Nederlands
Nl flag.gif

Ελληνικά
Gr flag.gif

Hrvatska
Hr flag.gif

Česká republika
Cz flag.gif

Danmark
Dk flag.gif

Polska
Pl flag.png

România
Ro flag.png

Sverige
Se flag.gif