ANALYSIS SURVIVAL DENGAN STATA
Description
[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 Declare data to be survival-time data
stdescribe Describe survival-time data stsum Summarize survival-time data stvary Report whether variables vary over time
stfill Fill in by carrying forward values of covariates stgen Generate variables reflecting entire histories
stsplit Split time-span records stjoin Join time-span records stbase Form baseline dataset sts Generate, graph, list, and test the survivor and cumulative hazard functions
stir Report incidence-rate comparison
stci Confidence intervals for means and percentiles of survival time
strate Tabulate failure rate stptime Calculate person-time
stmh 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.
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
+---+ | week status sex l_wbc rx | |---| 1. | 35 cencored male 1.45 treatmen | 2. | 34 cencored male 1.47 treatmen | 3. | 32 cencored male 2.2 treatmen | 4. | 32 cencored male 2.53 treatmen | 5. | 25 cencored male 1.78 treatmen | |---| 6. | 23 event male 2.57 treatmen | 7. | 22 event male 2.32 treatmen | 8. | 20 cencored male 2.01 treatmen | 9. | 19 cencored female 2.05 treatmen | 10. | 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: status != 0 & status < . obs. time interval: (0, week]
--- 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: status analysis time _t: week
Beg. Net Survivor 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 2 19 2 0 0.8095 0.0857 0.5689 0.9239 3 17 1 0 0.7619 0.0929 0.5194 0.8933 4 16 2 0 0.6667 0.1029 0.4254 0.8250 5 14 2 0 0.5714 0.1080 0.3380 0.7492 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) 0.00 0.25 0.50 0.75 1.00 0 10 20 30 40 analysis time rx = treatment rx = placebo
Kaplan-Meier survival estimates
.sts graph 0. 00 0. 25 0. 50 0. 75 1. 00 0 10 20 30 40 analysis time
Kaplan-Meier survival estimate
Probabilitas
Survive
s.d. time
ke..
Probabilitas
Survive s.d. time
ke..
. stsum, by (rx)
failure _d: status analysis time _t: 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
Median
Survival
. sts test rx, wilc failure _d: status analysis time _t: weekWilcoxon (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) = 13.46 Pr>chi2 = 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: status analysis time _t: week
Iteration 0: log likelihood = -93.98505 Iteration 1: log likelihood = -86.385606 Iteration 2: log likelihood = -86.379623 Iteration 3: log likelihood = -86.379622
Refining estimates:
Iteration 0: log likelihood = -86.379622 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(1) = 15.21 Log likelihood = -86.379622 Prob > chi2 = 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: status analysis time _t: week
Iteration 0: log likelihood = -93.98505 Iteration 1: log likelihood = -86.385606 Iteration 2: log likelihood = -86.379623 Iteration 3: log likelihood = -86.379622 Refining estimates:
Iteration 0: log likelihood = -86.379622 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(1) = 15.21 Log likelihood = -86.379622 Prob > chi2 = 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
1.
Graphic
sts graph, by (rx) sts graph, by (sex)
0.00 0.25 0.50 0.75 1.00 0 10 20 30 40 analysis time rx = treatment rx = placebo
Kaplan-Meier survival estimates
0.00 0.25 0.50 0.75 1.00 0 10 20 30 40 analysis time
sex = female sex = male
Kaplan-Meier survival estimates
Hazard tidak
proporsional
Hazard cukup
stphplot, by (rx) stphplot, by (sex) -1 0 1 2 3 -l n[-ln( Sur v ival Pr obability) ] 0 1 2 3 4 ln(analysis time) rx = treatment rx = placebo -1 0 1 2 3 -ln[ -ln(Surv iv al Probabilit y )] 0 1 2 3 4 ln(analysis time)
sex = female 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: status
analysis time _t: week
Iteration 0: log likelihood = -93.98505 Iteration 1: log likelihood = -86.385606 Iteration 2: log likelihood = -86.379623 Iteration 3: log likelihood = -86.379622 Refining estimates:
Iteration 0: log likelihood = -86.379622 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(1) = 15.21 Log likelihood = -86.379622 Prob > chi2 = 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 Time: Time --- | chi2 df Prob>chi2 ---+--- global test | 0.02 1 0.8913
Asumsi PH terpenuhi
---UJI ASUMSI PH VARIABEL SEX
. stcox sex, schoenfeld (sch*) scaledsch (sca*) failure _d: status
analysis time _t: week
Iteration 0: log likelihood = -93.98505 Iteration 1: log likelihood = -93.71683 Iteration 2: log likelihood = -93.716786 Refining estimates:
Iteration 0: log likelihood = -93.716786 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(1) = 0.54 Log likelihood = -93.716786 Prob > chi2 = 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
Test of proportional-hazards assumption Time: Time
--- | rho chi2 df Prob>chi2
Asumsi PH tidak terpenuhi
---+--- 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
Time-dependent covariate.
6. BASELINE SURVIVAL (So) dan BASELINE HAZARD (Ho)
Fungsi survival S (t) = [S
0(t)]
exp (β1 X1 + β2 X2 + ……+βn Xn)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 = -93.98505 Iteration 1: log likelihood = -72.418977 Iteration 2: log likelihood = -72.109348 Iteration 3: log likelihood = -72.109075 Refining estimates:
Iteration 0: log likelihood = -72.109075 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(3) = 43.75 Log likelihood = -72.109075 Prob > chi2 = 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 = -93.98505 Iteration 1: log likelihood = -72.418977 Iteration 2: log likelihood = -72.109348 Iteration 3: log likelihood = -72.109075 Refining estimates:
Iteration 0: log likelihood = -72.109075 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(3) = 43.75 Log likelihood = -72.109075 Prob > chi2 = 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
. sort _t . list _t So . list _t So Ho +---+ | _t So Ho | |---| 1. | 1 .99995849 .00003525 | 2. | 1 .99995849 .00003525 | 3. | 2 .99989223 .00008381 | 4. | 2 .99989223 .00008381 | 5. | 3 .99984204 .00013027 | |---| 6. | 4 .9997108 .00023895 | 7. | 4 .9997108 .00023895 | 8. | 5 .99952572 .00039628 | 9. | 5 .99952572 .00039628 | 10. | 6 .99917506 .00072579 | |---| 11. | 6 .99917506 .00072579 | 12. | 6 .99917506 .00072579 | 13. | 6 .99917506 .00072579 | 14. | 7 .99903776 .00085278 | 15. | 8 .99826929 .00144887 | |---| 16. | 8 .99826929 .00144887 | 17. | 8 .99826929 .00144887 | 18. | 8 .99826929 .00144887 | 19. | 9 .99826929 .00144887 | 20. | 10 .99800979 .00170511 | |---| 21. | 10 .99800979 .00170511 | 22. | 11 .99736099 .0022432 | 23. | 11 .99736099 .0022432 | 24. | 11 .99736099 .0022432 | 25. | 12 .99644782 .00304636 | |---| 26. | 12 .99644782 .00304636 | 27. | 13 .99591497 .00356741 | 28. | 15 .99534312 .00411664 | 29. | 16 .99465817 .00471769 | 30. | 17 .99368653 .00551119 | |---| 31. | 17 .99368653 .00551119 | 32. | 19 .99368653 .00551119 | 33. | 20 .99368653 .00551119 | 34. | 22 .98983386 .00825692 | 35. | 22 .98983386 .00825692 | |---| 36. | 23 .9819915 .01374523 | 37. | 23 .9819915 .01374523 | 38. | 25 .9819915 .01374523 | 39. | 32 .9819915 .01374523 | 40. | 32 .9819915 .01374523 | |---| 41. | 34 .9819915 .01374523 | 42. | 35 .9819915 .01374523 | +---+
Baseline Survival pada minggu ke 35 adalah 0.9819 atau 98,19%
7. APLIKASI ANALISIS SURVIVAL (Regresi Cox)
. stcox rx sex l_wbc, nohr
Iteration 0: log likelihood = -93.98505 Iteration 1: log likelihood = -72.418977 Iteration 2: log likelihood = -72.109348 Iteration 3: log likelihood = -72.109075 Refining estimates:
Iteration 0: log likelihood = -72.109075 Cox regression -- Breslow method for ties
No. of subjects = 42 Number of obs = 42 No. of failures = 30
Time at risk = 541
LR chi2(3) = 43.75 Log likelihood = -72.109075 Prob > chi2 = 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: