Stata 4, Survival
description
Transcript of Stata 4, Survival
Stata 4, Survival
Hein Stigum
Presentation, data and programs at:
http://folk.uio.no/heins/
04/22/23 1H.S.
Agenda
• Kaplan-Meier plots
• Cox regression
• Example– Age at first intercourse
04/22/23 2H.S.
Survival data
Status TimeNo debut CencoredDebut Event
01 debut age
age
Outcome:
• Unajusted analysis– Kaplan-Meier
• Regression method– Cox-regression
04/22/23 3H.S.
Survival data setup
• Status and timegenerate status=!missing(DebutAge)generate time=DebutAgereplace time=Age if status==0generate time2=time+uniform() avoid ties
• Set and describestset time, failure(status==1) Set datastdes Describe
04/22/23 4H.S.
Setting the timescale
Time = time since diagnosis in years: stset dateexit, failure(dead==1) origin(datediag) scale(365.25)
Time = age in years: stset dateexit, failure(dead==1) origin(datebth) enter(datediag) scale(365.25)
04/22/23 5H.S.
Mathematical functions
• Standard distribution functionsTime to event TDensity f(t)Cumulative density F(t)
• Survival functions
)()(1:Failure
)()(:hazard Cum.
)|()(:Hazard)()(:Survival
0
1
tFtS
dsshtH
tTtTdttPthtTPtS
tdt
04/22/23 6H.S.
Some relationships
))(ln()(
h(t)f(t)
small if )(1)(
)(
)(
)(
)(
tSdtdth
e
tHetF
etS
tH
tH
tH
04/22/23 7H.S.
Kaplan-Meier
• Survival function
• Syntaxsts graph, by(sex) KM survival plotsts test sex log-rank teststci, p(50) by(sex) time to 50% failurests list, at(5 10 30) survival at time 5,…
riskatrfailuresftS jjtt
rf
j
j
j
,),1()(
04/22/23 8H.S.
Kaplan-Meier, all0
.25
.5.7
51
10 15 20 25 30analysis time
Kaplan-Meier failure estimate
sts graph, fail gwood tmin(8) tmax(30) noorigin
Age at 50% failure:stci, p(50)
18.4 (18.1,18.8)
04/22/23 9H.S.
Kaplan-Meier, by sex0.
000.
250.
500.
751.
00
10 15 20 25 30Age
MalesFemales
Kaplan-Meier failure estimates, by gender
sts graph, fail by(gender) tmin(8) tmax(30) noorigin
Age at 50% failure: :stci, p(50) by (gender)Males: 18.6 (18.3,19.0)
Females: 18.1(17.8,18.9)
Log-rank test:sts test genderp-value=0.3
04/22/23 10H.S.
Hazards
0.1
.2.3
.4
10 15 20 25 30analysis time
Smoothed hazard estimates, by gender
sts graph, hazard by(gender) width(2)
04/22/23 11H.S.
Cox regression
...)exp()()( 22110 xbxbththx
hazard baseline RR
• Model
• Syntax– stcox x1 x2
• Proportional hazard test– stcox x1 x2, schoenfeld(sc*) scaledsch(ssc*)– estat phtest, detail– estat phtest, plot(x1)
04/22/23 12H.S.
Full model
stcox gender cohab partfrq
04/22/23 13H.S.
Proportion hazard testSave residuals:stcox gender cohab partfrq, schoenfeld(sc*) scaledsch(ssc*)Test:estat phtest, detail
04/22/23 14H.S.
Smoothed Schoenfeld residualsestat phtest, plot(cohab)
-50
5sc
aled
Sch
oenf
eld
- coh
ab
0 10 20 30 40Time
bandwidth = .8
Test of PH Assumption
04/22/23 15H.S.
Baseline hazard
0.1
.2.3
Sm
ooth
ed h
azar
d fu
nctio
n
10 15 20 25 30analysis time
Cox proportional hazards regression
stcox gender cohab partfrq, basesurv(bsurv) basehc(bhaz) stcurve, hazard at(gender=1 cohab=1 partfrq=0) range(8 30) width(1)
04/22/23 16H.S.
Predicted survivalstcurve, survival at1(gender=1 cohab=1 partfrq=0)
at2(gender=2 cohab=1 partfrq=0)
0.2
.4.6
.81
Sur
viva
l
10 15 20 25 30analysis time
Cox proportional hazards regression
04/22/23 17H.S.
If proptional hazard fails
• Stratified Cox regression
• Separate analysis on time intervals
• Time dependent covariats
• Additive model
04/22/23 18H.S.
Some Cox options
stcox drug age, strata(sex) Stratified
stcox drug age, shared(family) Frailty
stcox drug age, tvc(varlist) Timevar cov
04/22/23 19H.S.