|
|
|
||||
|
|
|||||
The data files used for the examples in this text can be downloaded in a zip file from the Wiley FTP website or the Stata Web site. You can then use a program such as WinZip to unzip the data files. If you need assistance getting data into Stata, please see our Stata Class Notes, especially the unit on Entering Data. (NOTE: The *.dat files are the data files, and the *.txt files contain the codebook information.)
Table 2.1, page 28.
input subj time censor
1 5 1
2 6 0
3 8 1
4 3 1
5 22 1
end
list
subj time censor
1. 1 5 1
2. 2 6 0
3. 3 8 1
4. 4 3 1
5. 5 22 1
Table 2.2, page 32.
stset time, failure(censor)
sts list, at(0 3 5 6 8 22)
failure _d: censor
analysis time _t: time
Beg. Survivor Std.
Time Total Fail Function Error [95% Conf. Int.]
-------------------------------------------------------------------------------
0 0 0 1.0000 . . .
3 5 1 0.8000 0.1789 0.2038 0.9692
5 4 1 0.6000 0.2191 0.1257 0.8818
6 3 0 0.6000 0.2191 0.1257 0.8818
8 2 1 0.3000 0.2387 0.0123 0.7192
22 1 1 0.0000 . . .
-------------------------------------------------------------------------------
Note: Survivor function is calculated over full data and evaluated at
indicated times; it is not calculated from aggregates shown at left.
Figure 2.2, page 32.
sts graph, censored(single) ylabel(0(.2)1) xlabel(0(5)25)
Figure 2.2, page 34.
use hmohiv, clear stset time, failure(censor) sts graph, censored(single) ylabel(0(.2)1) xlabel(0(10)60)
Parts of Table 2.3, page 35.
sts list
failure _d: censor
analysis time _t: time
Beg. Net Survivor Std.
Time Total Fail Lost Function Error [95% Conf. Int.]
-------------------------------------------------------------------------------
1 100 15 2 0.8500 0.0357 0.7636 0.9067
2 83 5 5 0.7988 0.0402 0.7057 0.8652
3 73 10 2 0.6894 0.0473 0.5862 0.7718
4 61 4 1 0.6442 0.0493 0.5387 0.7315
5 56 7 0 0.5636 0.0517 0.4564 0.6577
6 49 2 1 0.5406 0.0521 0.4334 0.6361
7 46 6 1 0.4701 0.0526 0.3644 0.5688
8 39 4 0 0.4219 0.0525 0.3183 0.5217
9 35 3 0 0.3857 0.0520 0.2845 0.4858
10 32 3 1 0.3496 0.0511 0.2514 0.4493
11 28 3 0 0.3121 0.0500 0.2177 0.4110
12 25 2 2 0.2872 0.0490 0.1956 0.3851
13 21 1 0 0.2735 0.0486 0.1835 0.3711
14 20 1 0 0.2598 0.0480 0.1715 0.3569
15 19 2 0 0.2325 0.0467 0.1479 0.3282
19 17 0 1 0.2325 0.0467 0.1479 0.3282
22 16 1 0 0.2179 0.0460 0.1355 0.3130
24 15 0 1 0.2179 0.0460 0.1355 0.3130
30 14 1 0 0.2024 0.0453 0.1222 0.2969
31 13 1 0 0.1868 0.0444 0.1092 0.2805
32 12 1 0 0.1712 0.0433 0.0966 0.2638
34 11 1 0 0.1557 0.0421 0.0843 0.2469
35 10 1 0 0.1401 0.0407 0.0724 0.2296
36 9 1 0 0.1245 0.0390 0.0610 0.2119
43 8 1 0 0.1090 0.0371 0.0500 0.1939
53 7 1 0 0.0934 0.0349 0.0396 0.1754
54 6 1 0 0.0778 0.0324 0.0298 0.1564
56 5 0 1 0.0778 0.0324 0.0298 0.1564
57 4 1 0 0.0584 0.0296 0.0178 0.1349
58 3 1 0 0.0389 0.0253 0.0082 0.1117
60 2 0 2 0.0389 0.0253 0.0082 0.1117
-------------------------------------------------------------------------------
Table 2.4, page 38 and Figure 2.5, page 39.
ltable time censor, interval(6) graph noconf xlab(0(20)80) ylab(0 .5 1)
Beg. Std.
Interval Total Deaths Lost Survival Error [95% Conf. Int.]
-------------------------------------------------------------------------------
0 6 100 41 10 0.5684 0.0508 0.4629 0.6608
6 12 49 21 3 0.3171 0.0498 0.2228 0.4154
12 18 25 6 2 0.2378 0.0467 0.1530 0.3334
18 24 17 1 1 0.2234 0.0460 0.1405 0.3184
24 30 15 0 1 0.2234 0.0460 0.1405 0.3184
30 36 14 5 0 0.1436 0.0412 0.0749 0.2339
36 42 9 1 0 0.1277 0.0396 0.0630 0.2160
42 48 8 1 0 0.1117 0.0377 0.0516 0.1977
48 54 7 1 0 0.0958 0.0355 0.0408 0.1790
54 60 6 3 1 0.0435 0.0260 0.0106 0.1155
60 66 2 0 2 0.0435 0.0260 0.0106 0.1155
-------------------------------------------------------------------------------
Figure 2.3, page 38.
generate t6 = recode(time,0,5,11,17,23,29,35,41,47,53,59,65) stset t6, failure(censor) sts graph, ylabel(0 .5 1)
Parts of Figure 2.5, page 46.
Note: Does not include Hall and Wellner confidence bands.
stset time, failure(censor) sts graph, gwood ylabel(0(.2)1) xlabel(0(10)60)
Parts of Table 2.5, page 50.
stsum
| incidence no. of |------ Survival time -----|
| time at risk rate subjects 25% 50% 75%
---------+---------------------------------------------------------------------
total | 1136 .0704225 100 3 7 15
stci, dd(2)
| no. of
| subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
total | 100 7.00 1.11 5 9
stci,dd(2) p(25)
| no. of
| subjects 25% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
total | 100 3.00 0.59 2 4
stci,dd(2) p(75)
| no. of
| subjects 75% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
total | 100 15.00 7.45 11 34
Table 2.6, page 52.
Note: There is an error in the book, the upper bound on the first line is incorrect.
sts list, at(4 5 to 9)
Beg. Survivor Std.
Time Total Fail Function Error [95% Conf. Int.]
-------------------------------------------------------------------------------
4 61 34 0.6442 0.0493 0.5387 0.7315
5 56 7 0.5636 0.0517 0.4564 0.6577
6 49 2 0.5406 0.0521 0.4334 0.6361
7 46 6 0.4701 0.0526 0.3644 0.5688
8 39 4 0.4219 0.0525 0.3183 0.5217
9 35 3 0.3857 0.0520 0.2845 0.4858
-------------------------------------------------------------------------------
Note: Survivor function is calculated over full data and evaluated at
indicated times; it is not calculated from aggregates shown at left.
Figure 2.7, page 58.
sts graph, by(drug) ylabel(0(.2)1) xlabel(0(10)60)
Table 2.11, page 65.
sts test drug, logrank
Log-rank test for equality of survivor functions
| Events Events
drug | observed expected
------+-------------------------
0 | 42 54.88
1 | 38 25.12
------+-------------------------
Total | 80 80.00
chi2(1) = 11.86
Pr>chi2 = 0.0006
sts test drug, w
Wilcoxon (Breslow) test for equality of survivor functions
[...table omitted...]
chi2(1) = 10.91
Pr>chi2 = 0.0010
sts test drug, tw
Tarone-Ware test for equality of survivor functions
[...table omitted...]
chi2(1) = 12.34
Pr>chi2 = 0.0004
sts test drug, p
Peto-Peto test for equality of survivor functions
[...table omitted...]
chi2(1) = 11.50
Pr>chi2 = 0.0007
Table 2.12, page 65.
generate agegrp = recode(age,29,34,39,54)
stci, by(agegrp)
| no. of
agegrp | subjects 50% Std. Err. [95% Conf. Interval]
-------------+-------------------------------------------------------------
29 | 12 43 8.095313 5 .
34 | 34 9 .8198685 6 12
39 | 25 7 .6573248 3 9
54 | 29 4 .3719542 2 5
-------------+-------------------------------------------------------------
total | 100 7 1.114345 5 9
Figure 2.8, page 69.
sts graph, by(agegrp)
Tables 2.14 and 2.15, page 70.
/* set agegrp2 to midpoint of age category */
recode agegrp 29=25 34=32.5 39=37.5 54=47.5, gen(agegrp2)
sts test agegrp2, trend
Log-rank test for equality of survivor functions
| Events Events
agegrp | observed expected
-------+-------------------------
29 | 8 19.89
34 | 29 29.43
39 | 20 17.81
54 | 23 12.87
-------+-------------------------
Total | 80 80.00
chi2(3) = 19.91
Pr>chi2 = 0.0002
Test for trend of survivor functions
chi2(1) = 19.07
Pr>chi2 = 0.0000
sts test agegrp2, trend w
Wilcoxon (Breslow) test for equality of survivor functions
[...table omitted...]
chi2(3) = 14.14
Pr>chi2 = 0.0027
Test for trend of survivor functions
chi2(1) = 14.08
Pr>chi2 = 0.0002
sts test agegrp2, trend tw
Tarone-Ware test for equality of survivor functions
[...table omitted...]
chi2(3) = 16.96
Pr>chi2 = 0.0007
Test for trend of survivor functions
chi2(1) = 16.67
Pr>chi2 = 0.0000
sts test agegrp2, trend p
Peto-Peto test for equality of survivor functions
[...table omitted...]
chi2(3) = 15.67
Pr>chi2 = 0.0013
Test for trend of survivor functions
chi2(1) = 15.54
Pr>chi2 = 0.0001
Table 2.17, page 76.
sts list, na
Beg. Net Nelson-Aalen Std.
Time Total Fail Lost Cum. Haz. Error [95% Conf. Int.]
-------------------------------------------------------------------------------
1 100 15 2 0.1500 0.0387 0.0904 0.2488
2 83 5 5 0.2102 0.0472 0.1354 0.3264
3 73 10 2 0.3472 0.0640 0.2419 0.4985
4 61 4 1 0.4128 0.0720 0.2933 0.5809
5 56 7 0 0.5378 0.0861 0.3930 0.7360
6 49 2 1 0.5786 0.0908 0.4254 0.7870
7 46 6 1 0.7091 0.1053 0.5301 0.9485
8 39 4 0 0.8116 0.1171 0.6117 1.0768
9 35 3 0 0.8973 0.1271 0.6798 1.1845
10 32 3 1 0.9911 0.1382 0.7541 1.3025
11 28 3 0 1.0982 0.1514 0.8382 1.4388
12 25 2 2 1.1782 0.1616 0.9005 1.5416
13 21 1 0 1.2258 0.1685 0.9364 1.6048
14 20 1 0 1.2758 0.1757 0.9740 1.6712
15 19 2 0 1.3811 0.1908 1.0534 1.8107
19 17 0 1 1.3811 0.1908 1.0534 1.8107
22 16 1 0 1.4436 0.2008 1.0991 1.8961
24 15 0 1 1.4436 0.2008 1.0991 1.8961
30 14 1 0 1.5150 0.2131 1.1499 1.9961
31 13 1 0 1.5920 0.2266 1.2044 2.1042
32 12 1 0 1.6753 0.2414 1.2630 2.2221
34 11 1 0 1.7662 0.2580 1.3265 2.3516
35 10 1 0 1.8662 0.2767 1.3956 2.4955
36 9 1 0 1.9773 0.2982 1.4714 2.6572
43 8 1 0 2.1023 0.3233 1.5552 2.8418
53 7 1 0 2.2452 0.3535 1.6491 3.0567
54 6 1 0 2.4118 0.3908 1.7556 3.3133
56 5 0 1 2.4118 0.3908 1.7556 3.3133
57 4 1 0 2.6618 0.4639 1.8916 3.7457
58 3 1 0 2.9952 0.5712 2.0610 4.3528
60 2 0 2 2.9952 0.5712 2.0610 4.3528
-------------------------------------------------------------------------------
Figure 2.10, page 77.
sts generate km = s sts generate na = na replace na = exp(-na) graph twoway scatter km na time, s(T O) c(J J) sort ylabel(0 .5 1)
Figure 2.12, page 82.
sts generate h = h replace h=0 if h==. graph twoway (lowess h time, bwidth(.99)) (scatter h time), ylabel(0 .35) xlabel(1 60)
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services