Sie sind auf Seite 1von 10

Survival analysis command > 1

ANALYSIS SURVIVAL DENGAN STATA


Description stmh Calculate rate ratios with
the Mantel-Haenszel method
[ST] st -- Survival-time data stmc Calculate rate ratios with
the Mantel-Cox method
The term st refers to survival-time data and the stcox Fit Cox proportional hazards
commands -- most of which begin with the letters st model
-- for analyzing these data. If you have data on estat concordance Calculate Harrell's C
individual subjects with observations recording that estat phtest Test Cox
this subject came under observation at time t0 and proportional-hazards
that later, at t1, a failure or censoring was assumption
observed, you have what we call survival-time data. stphplot Graphically assess the Cox
proportional-hazards
If you have subject-specific data, with observations assumption
recording not a span of time, but measurements taken stcoxkm Graphically assess the Cox
on the subject at that point in time, you have what proportional-hazards
we call a snapshot dataset; see [ST] snapspan. assumption
streg Fit parametric survival
If you have data on populations, with observations models
recording the number of units under test at time t stcurve Plot survivor, hazard, or
(subjects alive) and the number of subjects that cumulative hazard function
failed or were lost because of censoring, you have stpower Sample-size, power, and
what we call count-time data; see [ST] ct. effect-size determination
for survival studies
The st commands are stpower cox Sample size, power, and
effect size for the Cox
stset Declare data to be proportional hazards model
survival-time data stpower exponential Sample size and power for
stdescribe Describe survival-time data the exponential test
stsum Summarize survival-time data stpower logrank Sample size, power, and
stvary Report whether variables effect size for the
vary over time log-rank test
stfill Fill in by carrying forward sttocc Convert survival-time data
values of covariates to case-control data
stgen Generate variables sttoct Convert survival-time data
reflecting entire to count-time data
histories st_* Survival analysis
stsplit Split time-span records subroutines for
stjoin Join time-span records programmers
stbase Form baseline dataset
sts Generate, graph, list, and The st commands are used for analyzing
test the survivor and time-to-absorbing-event (single failure) data and for
cumulative hazard analyzing time-to-be-repeated-event (multiple
functions failure) data.
stir Report incidence-rate
comparison You begin an analysis by stsetting your data, which
stci Confidence intervals for tells Stata the key survival-time variables; see [ST]
means and percentiles of stset. Once you have stset your data, you can use
survival time the other st commands. If you save your data after
strate Tabulate failure rate stsetting it, you will not have to stset it again in
stptime Calculate person-time 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

+---------------------------------------------+
| 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]
exit on or before: 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: status Probabilitas


analysis time _t: week
Survive s.d. time
Beg. Net ke..
Std. Survivor
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 Probabilitas
0.9048 0.0641 0.6700 0.9753
2 19 2 0 0.8095
Survive 0.7619 0.0857 0.5689 0.9239
3 17 1 0 0.0929 0.5194 0.8933
4 16 2 0 s.d. time 0.6667 0.1029 0.4254 0.8250
5 14 2 0 ke.. 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) .sts graph

Kaplan-Meier survival estimates Kaplan-Meier survival estimate


1.00
1.00
0.75

0.75
0.50

0.50
0.25

0.25
0.00

0.00

0 10 20 30 40
analysis time 0 10 20 30 40
analysis time
rx = treatment rx = placebo
Survival analysis command > 4

. stsum, by (rx)

failure _d: status Median


analysis time _t: week Survival
| 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: status


analysis time _t: 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) = 13.46 Uji statistik


Pr>chi2 = 0.0002 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
Survival analysis command > 5

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 Hazard tidak


Hazard cukup proporsional
1. Graphic proporsional
sts graph, by (rx) sts graph, by (sex)
Kaplan-Meier survival estimates Kaplan-Meier survival estimates
1.00

1.00
0.75

0.75
0.50

0.50
0.25

0.25
0.00

0.00

0 10 20 30 40 0 10 20 30 40
analysis time analysis time

rx = treatment rx = placebo sex = female sex = male


Survival analysis command > 6

stphplot, by (rx) stphplot, by (sex)


3

3
-ln[-ln(Survival Probability)]

-ln[-ln(Survival Probability)]
2

2
1

1
0

0
-1

-1
0 1 2 3 4 0 1 2 3 4
ln(analysis time) ln(analysis time)

rx = treatment rx = placebo 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 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: 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
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 Time-
dependent 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 = -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
Survival analysis command > 9

. 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)


PERSAMAAN REGRESI COX:
Survival analysis command > 10

. 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:

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

Das könnte Ihnen auch gefallen