Survival analysis command > 1
ANALYSIS SURVIVAL DENGAN STATA Description
stmh
[ST] st -- Survival-time data The term st refers to survival-time data and the commands -- most of which begin with the letters st -- for analyzing these data. If you have data on individual subjects with observations recording that this subject came under observation at time t0 and that later, at t1, a failure or censoring was observed, you have what we call survival-time data. If you have subject-specific data, with observations recording not a span of time, but measurements taken on the subject at that point in time, you have what we call a snapshot dataset; see [ST] snapspan. If you have data on populations, with observations recording the number of units under test at time t (subjects alive) and the number of subjects that failed or were lost because of censoring, you have what we call count-time data; see [ST] ct. The st commands are stset stdescribe stsum stvary stfill stgen stsplit stjoin stbase sts
stir stci strate stptime
Declare data to be survival-time data Describe survival-time data Summarize survival-time data Report whether variables vary over time Fill in by carrying forward values of covariates Generate variables reflecting entire histories Split time-span records Join time-span records Form baseline dataset Generate, graph, list, and test the survivor and cumulative hazard functions Report incidence-rate comparison Confidence intervals for means and percentiles of survival time Tabulate failure rate Calculate person-time
Calculate rate ratios with the Mantel-Haenszel method stmc Calculate rate ratios with the Mantel-Cox method stcox Fit Cox proportional hazards model estat concordance Calculate Harrell's C estat phtest Test Cox proportional-hazards assumption stphplot Graphically assess the Cox proportional-hazards assumption stcoxkm Graphically assess the Cox proportional-hazards assumption streg Fit parametric survival models stcurve Plot survivor, hazard, or cumulative hazard function stpower Sample-size, power, and effect-size determination for survival studies stpower cox Sample size, power, and effect size for the Cox proportional hazards model stpower exponential Sample size and power for the exponential test stpower logrank Sample size, power, and effect size for the log-rank test sttocc Convert survival-time data to case-control data sttoct Convert survival-time data to count-time data st_* Survival analysis subroutines for programmers The st commands are used for analyzing time-to-absorbing-event (single failure) data and for analyzing time-to-be-repeated-event (multiple failure) data. You begin an analysis by stsetting your data, which tells Stata the key survival-time variables; see [ST] stset. Once you have stset your data, you can use the other st commands. If you save your data after stsetting it, you will not have to stset it again in the future; Stata will remember.
Survival analysis command > 2
1. PERSIAPAN ANALYSIS SURVIVAL Membuka/Open database dan melihat isi variabel. use "C:\SURVIVAL\anderson leukemia.dta", clear . des Contains data from C:\SURVIVAL\anderson leukemia.dta obs: 42 vars: 5 size: 504 (99.9% of memory free) ------------------------------------------------------------------------------storage display value variable name type format label variable label ------------------------------------------------------------------------------week byte %8.0g status byte %8.0g status sex byte %8.0g sex l_wbc float %9.0g rx byte %8.0g rx ------------------------------------------------------------------------------. list
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
+---------------------------------------------+ | week status sex l_wbc rx | |---------------------------------------------| | 35 cencored male 1.45 treatmen | | 34 cencored male 1.47 treatmen | | 32 cencored male 2.2 treatmen | | 32 cencored male 2.53 treatmen | | 25 cencored male 1.78 treatmen | |---------------------------------------------| | 23 event male 2.57 treatmen | | 22 event male 2.32 treatmen | | 20 cencored male 2.01 treatmen | | 19 cencored female 2.05 treatmen | | 17 cencored female 2.16 treatmen |
................ dst
2. SETING TIME & EVENT Memberikan perintah kepada stata untuk membaca variabel time (var_time) dan event (var_event) dengan perintah sbb: . stset var_time, failure (var_event)
Ganti var_time dengan variabel waktu yang ada pada data (bisa jam, hari, minggu, bulan, tahun, dll) dan var_event dengan variabel event yang ada pada data (bisa status, mati, sehat, kambuh, dll) Pada data Anderson leukemia.dta vari_time adalah week dan var_event adalah status, maka perintah seting time dan event adalah sbb: . stset week, failure (status) failure event: obs. time interval: exit on or before:
status != 0 & status < . (0, week] failure
Survival analysis command > 3
-----------------------------------------------------------------------------42 total obs. 0 exclusions -----------------------------------------------------------------------------42 obs. remaining, representing 30 failures in single record/single failure data 541 total analysis time at risk, at risk from t = 0 earliest observed entry t = 0 last observed exit t = 35
3. PERBEDAAN SURVIVAL MENURUT RX . sts list, by (rx) failure _d: analysis time _t:
Probabilitas Survive s.d. time ke.. Survivor
status week
Beg. Net Std. Time Total Fail Lost Function Error [95% Conf. Int.] ------------------------------------------------------------------------------treatment 6 21 3 1 0.8571 0.0764 0.6197 0.9516 7 17 1 0 0.8067 0.0869 0.5631 0.9228 9 16 0 1 0.8067 0.0869 0.5631 0.9228 10 15 1 1 0.7529 0.0963 0.5032 0.8894 11 13 0 1 0.7529 0.0963 0.5032 0.8894 13 12 1 0 0.6902 0.1068 0.4316 0.8491 16 11 1 0 0.6275 0.1141 0.3675 0.8049 17 10 0 1 0.6275 0.1141 0.3675 0.8049 19 9 0 1 0.6275 0.1141 0.3675 0.8049 20 8 0 1 0.6275 0.1141 0.3675 0.8049 22 7 1 0 0.5378 0.1282 0.2678 0.7468 23 6 1 0 0.4482 0.1346 0.1881 0.6801 25 5 0 1 0.4482 0.1346 0.1881 0.6801 32 4 0 2 0.4482 0.1346 0.1881 0.6801 34 2 0 1 0.4482 0.1346 0.1881 0.6801 35 1 0 1 0.4482 0.1346 0.1881 0.6801 placebo 1 21 2 0 0.9048 0.0641 0.6700 0.9753 Probabilitas 2 19 2 0 0.8095 0.0857 0.5689 0.9239 Survive 0.7619 3 17 1 0 0.0929 0.5194 0.8933 s.d. time 0.6667 4 16 2 0 0.1029 0.4254 0.8250 5 14 2 0 0.5714 0.1080 0.3380 0.7492 ke.. 8 12 4 0 0.3810 0.1060 0.1831 0.5778 11 8 2 0 0.2857 0.0986 0.1166 0.4818 12 6 2 0 0.1905 0.0857 0.0595 0.3774 15 4 1 0 0.1429 0.0764 0.0357 0.3212 17 3 1 0 0.0952 0.0641 0.0163 0.2612 22 2 1 0 0.0476 0.0465 0.0033 0.1970 23 1 1 0 0.0000 . . . .sts graph, by (rx)
.sts graph
1.00
Kaplan-Meier survival estimate
0
10
20 analysis time rx = treatment
30
40
0.00
0.00
0.25
0.25
0.50
0.50
0.75
0.75
1.00
Kaplan-Meier survival estimates
0
rx = placebo
10
20 analysis time
30
40
Survival analysis command > 4
. stsum, by (rx) failure _d: analysis time _t:
Median Survival
status week
| incidence no. of |------ Survival time -----| rx | time at risk rate subjects 25% 50% 75% ---------+--------------------------------------------------------------------treatmen | 359 .0250696 21 13 23 . placebo | 182 .1153846 21 4 8 12 ---------+--------------------------------------------------------------------total | 541 .0554529 42 6 12 23
. sts test rx, wilc failure _d: analysis time _t:
status week
Wilcoxon (Breslow) test for equality of survivor functions | Events Events Sum of rx | observed expected ranks ----------+-------------------------------------treatment | 9 19.25 -271 placebo | 21 10.75 271 ----------+-------------------------------------Total | 30 30.00 0 chi2(1) = Pr>chi2 =
13.46 0.0002
Uji statistik perbedaan survival
4. REGRESI COX Perintah regresi untuk menampilkan Hazard Ratio adalah sbb: stcox dep_var1 dep_var2 dep_var3 dst....
Perintah regresi untuk menampilkan Coeficien adalah sbb: stcox dep_var1 dep_var2 dep_var3, nohr
Catatan: Perintah tersebut hanya bisa dijalankan setelah seting time dan event dilakukan
REGRESI COX BIVARIATE . stcox rx failure _d: analysis time _t: Iteration Iteration Iteration Iteration
0: 1: 2: 3:
log log log log
status week
likelihood likelihood likelihood likelihood
= -93.98505 = -86.385606 = -86.379623 = -86.379622
Survival analysis command > 5
Refining estimates: Iteration 0: log likelihood = -86.379622 Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -86.379622
Number of obs
=
42
LR chi2(1) Prob > chi2
= =
15.21 0.0001
-----------------------------------------------------------------------------_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------rx | 4.523072 1.852489 3.68 0.000 2.026804 10.09382 ------------------------------------------------------------------------------
. stcox rx, nohr failure _d: analysis time _t:
status week
Iteration 0: log likelihood Iteration 1: log likelihood Iteration 2: log likelihood Iteration 3: log likelihood Refining estimates: Iteration 0: log likelihood
= -93.98505 = -86.385606 = -86.379623 = -86.379622 = -86.379622
Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -86.379622
Number of obs
=
42
LR chi2(1) Prob > chi2
= =
15.21 0.0001
-----------------------------------------------------------------------------_t | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------rx | 1.509191 .4095644 3.68 0.000 .7064599 2.311923 ------------------------------------------------------------------------------
5. CEK ASUMSI PROPORTIONAL HAZARD Hazard cukup proporsional
1. Graphic sts graph, by (rx)
sts graph, by (sex) Kaplan-Meier survival estimates
0.75 0.50 0.25 0.00
0.00
0.25
0.50
0.75
1.00
Kaplan-Meier survival estimates
1.00
Hazard tidak proporsional
0
10
20 analysis time rx = treatment
30 rx = placebo
40
0
10
20 analysis time sex = female
30 sex = male
40
Survival analysis command > 6
stphplot, by (sex)
-1
-1
-ln[-ln(Survival Probability)] 0 1 2
-ln[-ln(Survival Probability)] 0 1 2
3
3
stphplot, by (rx)
0
1
2 ln(analysis time) rx = treatment
3
4
rx = placebo
0
1
2 ln(analysis time) sex = female
3
4
sex = male
2. Global test 1. Jalankan perintah regresi cox: stcox rx sex l_wbc, schoenfeld (sch*) scaledsch (sca*) 2. Jalankan PH asumsi dengan Global test: stphtest 3. Minta detail dari Global test: stphtest, detail
Catatan: Perintah tersebut hanya bisa dijalankan setelah seting time dan event dilakukan UJI ASUMSI PH VARIABEL RX . stcox rx, schoenfeld (sch*) scaledsch (sca*) failure _d: analysis time _t:
status week
Iteration 0: log likelihood Iteration 1: log likelihood Iteration 2: log likelihood Iteration 3: log likelihood Refining estimates: Iteration 0: log likelihood
= -93.98505 = -86.385606 = -86.379623 = -86.379622 = -86.379622
Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -86.379622
Number of obs
=
42
LR chi2(1) Prob > chi2
= =
15.21 0.0001
-----------------------------------------------------------------------------_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------rx | 4.523072 1.852489 3.68 0.000 2.026804 10.09382 -----------------------------------------------------------------------------. stphtest Test of proportional-hazards assumption
Asumsi PH terpenuhi
Time: Time ---------------------------------------------------------------| chi2 df Prob>chi2 ------------+--------------------------------------------------global test | 0.02 1 0.8913 ----------------------------------------------------------------
Survival analysis command > 7
UJI ASUMSI PH VARIABEL SEX . stcox sex, schoenfeld (sch*) scaledsch (sca*) failure _d: analysis time _t:
status week
Iteration 0: log likelihood Iteration 1: log likelihood Iteration 2: log likelihood Refining estimates: Iteration 0: log likelihood
= -93.98505 = -93.71683 = -93.716786 = -93.716786
Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -93.716786
Number of obs
=
42
LR chi2(1) Prob > chi2
= =
0.54 0.4639
-----------------------------------------------------------------------------_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------sex | .7462828 .3001652 -0.73 0.467 .3392646 1.641604 -----------------------------------------------------------------------------. . stphtest, detail
Asumsi PH tidak terpenuhi
Test of proportional-hazards assumption Time: Time ---------------------------------------------------------------| rho chi2 df Prob>chi2 ------------+--------------------------------------------------sex | -0.52263 10.28 1 0.0013 ------------+--------------------------------------------------global test | 10.28 1 0.0013 ----------------------------------------------------------------
Karena asumsi proportional hazard tidak terpenuhi untuk variabel SEX, maka pemodelan yang dipakai adalah Extended, artinya dibuat dua model terpisah antara jenis kelamin laki2 dengan jenis kelamin perempuan. Atau dibuat dua model yang terpisah antara sebelum titik potong kurva survival jenis kelamin (time < time titik potong) dengan sesudah titik potong kurva survival jenis kelamin (time >= time titik potong). Atau gunakan metode statistik yang lain, misalnya SPSS dengan Regresi Cox with Timedependent covariate.
6. BASELINE SURVIVAL (So) dan BASELINE HAZARD (Ho) Fungsi survival
S (t) = [S0 (t)] exp (β1 X1 + β2 X2 + ……+βn Xn)
. FUNGSI HAZARD = Ho(t) exp(b1*x1 + b2*x2 + .... + bn*xn) ????
Survival analysis command > 8
Untuk menghitung survival rate pada waktu tertentu dan sesuai karakteristik tertentu maka perlu ditentukan Baseline Survival (Survival pada time=t) terlebih dahulu. Begitu juga halnya untuk menghitung hazard rate pada waktu tertentu dan sesuai karakteristik tertentu maka perlu ditentukan Baseline Hazard (Hazard pada time=t) terlebih dahulu
Perhitungan Baseline Survival dan Baseline Hazard adalah dengan perintah sbb: stcox dep_var1 dep_var2 dep_var3, basesurv(So) stcox dep_var1 dep_var2 dep_var3, basechazard(Ho) sort _t list _t So Ho Contoh: . use "C:\SURVIVAL\anderson leukemia.dta", clear . stset week, failure (status) . stcox rx sex l_wbc, basesurv(So) Iteration 0: log likelihood Iteration 1: log likelihood Iteration 2: log likelihood Iteration 3: log likelihood Refining estimates: Iteration 0: log likelihood
= -93.98505 = -72.418977 = -72.109348 = -72.109075 = -72.109075
Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -72.109075
Number of obs
=
42
LR chi2(3) Prob > chi2
= =
43.75 0.0000
-----------------------------------------------------------------------------_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------rx | 4.018371 1.834972 3.05 0.002 1.641922 9.834394 sex | 1.301049 .5847372 0.59 0.558 .5391797 3.13945 l_wbc | 4.921527 1.624083 4.83 0.000 2.577549 9.397078 -----------------------------------------------------------------------------. stcox rx sex l_wbc, basechazard(Ho) Iteration 0: log likelihood Iteration 1: log likelihood Iteration 2: log likelihood Iteration 3: log likelihood Refining estimates: Iteration 0: log likelihood
= -93.98505 = -72.418977 = -72.109348 = -72.109075 = -72.109075
Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -72.109075
Number of obs
=
42
LR chi2(3) Prob > chi2
= =
43.75 0.0000
-----------------------------------------------------------------------------_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------rx | 4.018371 1.834972 3.05 0.002 1.641922 9.834394 sex | 1.301049 .5847372 0.59 0.558 .5391797 3.13945 l_wbc | 4.921527 1.624083 4.83 0.000 2.577549 9.397078
Survival analysis command > 9
. sort _t . list . list
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42.
_t So _t So Ho
+----------------------------+ | _t So Ho | |----------------------------| | 1 .99995849 .00003525 | | 1 .99995849 .00003525 | | 2 .99989223 .00008381 | | 2 .99989223 .00008381 | | 3 .99984204 .00013027 | |----------------------------| | 4 .9997108 .00023895 | | 4 .9997108 .00023895 | | 5 .99952572 .00039628 | | 5 .99952572 .00039628 | | 6 .99917506 .00072579 | |----------------------------| | 6 .99917506 .00072579 | | 6 .99917506 .00072579 | | 6 .99917506 .00072579 | | 7 .99903776 .00085278 | | 8 .99826929 .00144887 | |----------------------------| | 8 .99826929 .00144887 | | 8 .99826929 .00144887 | | 8 .99826929 .00144887 | | 9 .99826929 .00144887 | | 10 .99800979 .00170511 | |----------------------------| | 10 .99800979 .00170511 | | 11 .99736099 .0022432 | | 11 .99736099 .0022432 | | 11 .99736099 .0022432 | | 12 .99644782 .00304636 | |----------------------------| | 12 .99644782 .00304636 | | 13 .99591497 .00356741 | | 15 .99534312 .00411664 | | 16 .99465817 .00471769 | | 17 .99368653 .00551119 | |----------------------------| | 17 .99368653 .00551119 | | 19 .99368653 .00551119 | | 20 .99368653 .00551119 | | 22 .98983386 .00825692 | | 22 .98983386 .00825692 | |----------------------------| | 23 .9819915 .01374523 | | 23 .9819915 .01374523 | | 25 .9819915 .01374523 | | 32 .9819915 .01374523 | | 32 .9819915 .01374523 | |----------------------------| | 34 .9819915 .01374523 | | 35 .9819915 .01374523 | +----------------------------+
Baseline Survival pada minggu ke 35 adalah 0.9819 atau 98,19%
7. APLIKASI ANALISIS SURVIVAL (Regresi Cox) PERSAMAAN REGRESI COX:
Survival analysis command > 10
. stcox rx sex l_wbc, nohr Iteration 0: log likelihood Iteration 1: log likelihood Iteration 2: log likelihood Iteration 3: log likelihood Refining estimates: Iteration 0: log likelihood
= -93.98505 = -72.418977 = -72.109348 = -72.109075 = -72.109075
Cox regression -- Breslow method for ties No. of subjects = No. of failures = Time at risk = Log likelihood
=
42 30 541 -72.109075
Number of obs
=
42
LR chi2(3) Prob > chi2
= =
43.75 0.0000
-----------------------------------------------------------------------------_t | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------rx | 1.390877 .4566458 3.05 0.002 .4958673 2.285886 sex | .2631706 .4494353 0.59 0.558 -.6177064 1.144048 l_wbc | 1.593619 .3299958 4.83 0.000 .9468389 2.240399
FUNGSI SURVIVAL:
S (t) = [S0 (t)] exp (1.391 * RX + 0.263 * Sex + 1.594 * L_wbc) CONTOH APLIKASI FUNGSI SURVIVAL:
1. Seseorang dengan rx=0 (mendapat treatment), sex=0 (perempuan), dan l_wbc=1,5, maka probabilitas survivalnya sampai minggu ke 35 adalah sbb:
S (t) = [S0 (t)] exp (1.391 * RX + 0.263 * Sex + 1.594 * L_wbc) S35 = 0.98199 ^ (exp ((1.391*0) + (0.263*0) + (1.594*1.5))) = 0.8199 = 82% Kemungkianan untuk survive setelah minggu ke-35 adalah 82% 2. Seseorang dengan rx=1 (tidak mendapat treatment), sex=0 (perempuan), dan l_wbc=1,5, maka probabilitas survivalnya sampai minggu ke 35 adalah sbb: S35 = 0.98199 ^ (exp ((1.391*1) + (0.263*0) + (1.594*1.5))) = 0.0000 = 0% Kemungkianan untuk survive setelah minggu ke-35 adalah 0% gen S35 = 0.98199 ^ (exp ((1.391*rx) + (0.263*sex) + (1.594*l_wbc))) list id rx sex l_wbc S35 if id==2 | id==10| id==30