clear all
use "C:\Users\Fares\Documents\PH539\lymphoma.dta"
/*********************
Plot Kaplan-Meier Survival curves of lymphoma patients by
stage of tumor.
See Armitage et al. 2002, Table 17.3.
McKelvey et al., 1976.
***********************/
/*Two variables must be defined to
give each patient’s length of
follow-up and fate at exit. In
this example, these variables are
called time and fate respectively.*/
codebook fate
/***
stset specifies that the data set contains survival data, with each
patient’s exit time denoted by time and status at exit denoted by
fate. Stata interprets fate = 0 to mean that the patient is
censored at exit and fate !=0 to mean that subject suffered the event
of interest at exit.
****/
stset time, failure (fate)
/***
sts graph plots Kaplan-Meier survival curves.
by(stage) specifies that separate plots will
be generated for each value of stage. The yaxis
title is Probability of Survival.
****/
sts graph, by(stage) ytitle(Probability of Survival)
/**
The accuracy of the survival curve gets less as we move
towards the right, as it is based on fewer and fewer patients
**/
sts graph, by(stage) ytitle(Cumulative Mortality) failure
*
* List survival statistics
*
sts list, by(stage)
sts list, by(stage) at (30 40 50)
sts list, by(stage) at (30 40 50) failure
*
* Kaplan-Meier survival curves by stage with 95% CIs
*
sts graph, by(stage) ci censored(single) separate ///
xlabel(0 (50) 350) xmtick(0 (25) 350) ///
byopts(title(, size(0)) legend(off)) ///
ytitle(Probability of Survival) ///
ylabel(0 (.1) 1, angle(0)) ciopts(color(yellow)) ///
xtitle(Days Since Recruitment) ymtick(0 (.05) 1)
*
* Kaplan-Meier morbidity curves by stage with risk table
*
sts graph, by(stage) failure ///
risktable(,order(2 "Stage 4" 1 "Stage 3")) ///
ytitle(Cumulative Mortality) ///
xlabel(0 (50) 350) xmtick(0 (25) 350) ///
ylabel(0 (.1) .8, angle(0)) ///
xtitle(Days Since Recruitment) ymtick(0 (.05) .8) ///
title(" ",size(0)) legend(ring(0) cols(1) ///
position(11) order(2 "Stage 4" 1 "Stage 3"))
*
* Perform log-rank test to compare stage 3 and 4 survival
*
sts test stage
/**
The tabulate command cross-tabulates patients by stage and fate.
The exact option calculates Fisher’s exact test of the hypothesis
that the proportion of deaths in the two groups are equal. Fisher’s
exact test differs from the log-rank test in that the latter takes
into consideration time to death as well as numbers of deaths
while the former only considers numbers of deaths. In this
example, the two tests give very similar results.
**/
tabulate stage fate, exact
*
* Perform proportional hazards regression analysis of
* lymphoma patients by stage of tumor.
*
stcox stage
stcox stage, nohr