*********************************************************************** * * * NewLarynx-do.txt * * * * PURPOSE: analysis of laryngeal cancer data * * * * DATE: 01/05/21 * * * *********************************************************************** *** *** input the data and label *** infile stage time age year status using larynx.dat label variable stage "stage at diagnosis" label variable time "time (years)" label variable age "age" label variable year "year of entry" label variable status "status" gen stage34 = stage recode stage34 1/2=0 3/4=1 stset time, failure(status) *** *** Cox regression *** xi: stcox i.stage lrtest, saving(0) stcox stage lrtest, saving(1) lrtest, model(0) using(1) *** *** Cox regression -- can I create the coxkm curves? *** xi: stcox i.stage, basesurv( s0 ) *** *** create fitted survival curves *** generate s1 = s0 generate s2 = s0^( exp( _b[ _Istage_2 ] ) ) generate s3 = s0^( exp( _b[ _Istage_3 ] ) ) generate s4 = s0^( exp( _b[ _Istage_4 ] ) ) sort time graph s1 s2 s3 s4 time, saving("larynx-Sfit1.gph") connect(l l l l) yscale(0,1) translate larynx-Sfit1.gph larynx-Sfit1.eps *** *** Cox regression -- can I create the coxkm curves? *** stcox stage, basesurv( s0L ) *** *** create fitted survival curves *** generate s1L = s0L^( exp( _b[ stage ] ) ) generate s2L = s0L^( exp( _b[ stage ]*2 ) ) generate s3L = s0L^( exp( _b[ stage ]*3 ) ) generate s4L = s0L^( exp( _b[ stage ]*4 ) ) sort time graph s1L s2L s3L s4L time, saving("larynx-Sfit2.gph") connect(l l l l) yscale(0,1) translate larynx-Sfit2.gph larynx-Sfit2.eps