Stata program for Probit/Logit Models


STATA Results for Duration Data


Download 230.5 Kb.
bet9/9
Sana23.03.2023
Hajmi230.5 Kb.
#1287378
1   2   3   4   5   6   7   8   9
Bog'liq
STATA Programs

STATA Results for Duration Data
surv_data.log

------------------------------------------------------------------------------


log: c:\bill\jpsm\surv_data.log
log type: text
opened on: 7 Nov 2004, 06:26:56

. * load up sas data set;


. use c:\bill\jpsm\surv_data;

. * get contents of data file;


. desc;

Contains data from c:\bill\jpsm\surv_data.dta


obs: 26,654
vars: 7 2 Nov 2004 10:59
size: 533,080 (97.5% of memory free)
------------------------------------------------------------------------------
> -
storage display value
variable name type format label variable label
------------------------------------------------------------------------------
> -
age_s_yrs byte %9.0g age in years at the time of
survey
max_mths byte %9.0g max months of followup
black byte %9.0g dummy variable, =1 if black
hispanic byte %9.0g dummy variable, =1 hispanic
income float %9.0g =1 if <10K, 2 if 10-20, 3 if
20-30, 4 if 30-40, 5 if 40+
educ float %9.0g =1 if <9, =2 if 9-11, =3 if
12-15, =4 if 16+
diedin5 float %9.0g died with 5 year followup
------------------------------------------------------------------------------
> -
Sorted by:

. * get summary statistics;


. sum;

Variable | Obs Mean Std. Dev. Min Max


-------------+--------------------------------------------------------
age_s_yrs | 26654 59.42586 5.962435 50 70
max_mths | 26654 56.49077 11.15384 0 60
black | 26654 .0928566 .2902368 0 1
hispanic | 26654 .0454716 .20834 0 1
income | 26654 3.592181 1.327325 1 5
-------------+--------------------------------------------------------
educ | 26654 2.766677 .961846 1 4
diedin5 | 26654 .1226082 .3279931 0 1

. * define the duration data in the analysis;


. stset max_mths, failure(diedin5);

failure event: diedin5 != 0 & diedin5 < .


obs. time interval: (0, max_mths]
exit on or before: failure

------------------------------------------------------------------------------


26654 total obs.
23 obs. end on or before enter()
------------------------------------------------------------------------------
26631 obs. remaining, representing
3245 failures in single record/single failure data
1505705 total analysis time at risk, at risk from t = 0
earliest observed entry t = 0
last observed exit t = 60

. * list the kaplan meier survivor function;


. sts list;

failure _d: diedin5


analysis time _t: max_mths

Beg. Net Survivor Std.


Time Total Fail Lost Function Error [95% Conf. Int.
> ]
------------------------------------------------------------------------------
> -
1 26631 38 0 0.9986 0.0002 0.9980 0.999
> 0
2 26593 42 0 0.9970 0.0003 0.9963 0.997
> 6
3 26551 40 0 0.9955 0.0004 0.9946 0.996
> 2
4 26511 49 0 0.9937 0.0005 0.9926 0.994
> 5
5 26462 50 0 0.9918 0.0006 0.9906 0.992
> 8
6 26412 61 0 0.9895 0.0006 0.9882 0.990
> 6
7 26351 45 0 0.9878 0.0007 0.9864 0.989
> 0
8 26306 60 0 0.9855 0.0007 0.9840 0.986
> 9
9 26246 46 0 0.9838 0.0008 0.9822 0.985
> 3
10 26200 42 0 0.9822 0.0008 0.9806 0.983
> 8
11 26158 52 0 0.9803 0.0009 0.9785 0.981
> 9
12 26106 56 0 0.9782 0.0009 0.9764 0.979
> 9
13 26050 53 0 0.9762 0.0009 0.9743 0.978
> 0
14 25997 64 0 0.9738 0.0010 0.9718 0.975
> 6
15 25933 48 0 0.9720 0.0010 0.9699 0.973
> 9
16 25885 49 0 0.9701 0.0010 0.9680 0.972
> 1
17 25836 54 0 0.9681 0.0011 0.9659 0.970
> 2
18 25782 46 0 0.9664 0.0011 0.9642 0.968
> 5
19 25736 51 0 0.9645 0.0011 0.9622 0.966
> 6
20 25685 38 0 0.9631 0.0012 0.9607 0.965
> 2
21 25647 56 0 0.9609 0.0012 0.9586 0.963
> 2
22 25591 51 0 0.9590 0.0012 0.9566 0.961
> 3
23 25540 48 0 0.9572 0.0012 0.9547 0.959
> 6
24 25492 51 0 0.9553 0.0013 0.9528 0.957
> 7
25 25441 59 0 0.9531 0.0013 0.9505 0.955
> 6
26 25382 58 0 0.9509 0.0013 0.9483 0.953
> 5
27 25324 63 0 0.9486 0.0014 0.9458 0.951
> 1
28 25261 50 0 0.9467 0.0014 0.9439 0.949
> 3
29 25211 50 0 0.9448 0.0014 0.9420 0.947
> 5
30 25161 52 0 0.9428 0.0014 0.9400 0.945
> 6
31 25109 60 0 0.9406 0.0014 0.9377 0.943
> 4
32 25049 52 0 0.9386 0.0015 0.9357 0.941
> 5
33 24997 54 0 0.9366 0.0015 0.9336 0.939
> 5
34 24943 56 0 0.9345 0.0015 0.9315 0.937
> 4
35 24887 66 0 0.9320 0.0015 0.9289 0.935
> 0
36 24821 70 0 0.9294 0.0016 0.9263 0.932
> 4
37 24751 45 0 0.9277 0.0016 0.9245 0.930
> 8
38 24706 59 0 0.9255 0.0016 0.9223 0.928
> 6
39 24647 54 0 0.9235 0.0016 0.9202 0.926
> 6
40 24593 48 0 0.9217 0.0016 0.9184 0.924
> 8
41 24545 61 0 0.9194 0.0017 0.9160 0.922
> 6
42 24484 63 0 0.9170 0.0017 0.9136 0.920
> 3
43 24421 56 0 0.9149 0.0017 0.9115 0.918
> 2
44 24365 52 0 0.9130 0.0017 0.9095 0.916
> 3
45 24313 60 0 0.9107 0.0017 0.9072 0.914
> 1
46 24253 56 0 0.9086 0.0018 0.9051 0.912
> 0
47 24197 68 0 0.9060 0.0018 0.9025 0.909
> 5
48 24129 59 0 0.9038 0.0018 0.9002 0.907
> 3
49 24070 57 0 0.9017 0.0018 0.8981 0.905
> 2
50 24013 57 0 0.8996 0.0018 0.8959 0.903
> 1
51 23956 66 0 0.8971 0.0019 0.8934 0.900
> 7
52 23890 57 0 0.8949 0.0019 0.8912 0.898
> 6
53 23833 50 0 0.8931 0.0019 0.8893 0.896
> 7
54 23783 53 0 0.8911 0.0019 0.8873 0.894
> 7
55 23730 64 0 0.8887 0.0019 0.8848 0.892
> 4
56 23666 55 0 0.8866 0.0019 0.8827 0.890
> 3
57 23611 65 0 0.8842 0.0020 0.8803 0.887
> 9
58 23546 66 0 0.8817 0.0020 0.8777 0.885
> 5
59 23480 44 0 0.8800 0.0020 0.8761 0.883
> 9
60 23436 50 2.3e+04 0.8781 0.0020 0.8742 0.8
> 820
------------------------------------------------------------------------------
> -

. * you can graph the functions as well;


. * output the graphs to a file;
. sts graph;

failure _d: diedin5


analysis time _t: max_mths

. graph save c:\bill\jpsm\graph1.gph, replace;


(file c:\bill\jpsm\graph1.gph saved)

. * you can draw graphs for various subgroups;


. * output the graphs to a file;
. sts graph, by(educ);

failure _d: diedin5


analysis time _t: max_mths

. graph save c:\bill\jpsm\graph2.gph, replace;


(file c:\bill\jpsm\graph2.gph saved)

. * run a duration model where the hazard varies across;


. * people. first, ask stata to print out the raw;
. * coefficients (nohr option), then do default;
. * show weibull first, then exponential;
. * first, construct dummies for the income and;
. * education categories. in the regression statement;
. * _Ie star include all variables beginning with _Ie;
. * and _Ii star includes all variables starting with;
. * _Ii;
. xi i.income i.educ;
i.income _Iincome_1-5 (naturally coded; _Iincome_1 omitted)
i.educ _Ieduc_1-4 (naturally coded; _Ieduc_1 omitted)

. streg age_s_yrs black hispanic _Ie* _Ii*, d(weibull) nohr;


failure _d: diedin5


analysis time _t: max_mths

Fitting constant-only model:


Iteration 0: log likelihood = -12759.823


Iteration 1: log likelihood = -12723.121
Iteration 2: log likelihood = -12722.924
Iteration 3: log likelihood = -12722.924

Fitting full model:


Iteration 0: log likelihood = -12722.924


Iteration 1: log likelihood = -12454.553
Iteration 2: log likelihood = -12425.111
Iteration 3: log likelihood = -12425.055
Iteration 4: log likelihood = -12425.055

Weibull regression -- log relative-hazard form


No. of subjects = 26631 Number of obs = 26631


No. of failures = 3245
Time at risk = 1505705
LR chi2(10) = 595.74
Log likelihood = -12425.055 Prob > chi2 = 0.0000

------------------------------------------------------------------------------


_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age_s_yrs | .0452588 .0031592 14.33 0.000 .0390669 .0514508
black | .4770152 .0511122 9.33 0.000 .3768371 .5771932
hispanic | .1333552 .082156 1.62 0.105 -.0276676 .294378
_Ieduc_2 | .0093353 .0591918 0.16 0.875 -.1066786 .1253492
_Ieduc_3 | -.072163 .0503131 -1.43 0.151 -.1707748 .0264488
_Ieduc_4 | -.1301173 .0657131 -1.98 0.048 -.2589126 -.0013221
_Iincome_2 | -.1867752 .0650604 -2.87 0.004 -.3142914 -.0592591
_Iincome_3 | -.3268927 .0688635 -4.75 0.000 -.4618627 -.1919227
_Iincome_4 | -.5166137 .0769202 -6.72 0.000 -.6673747 -.3658528
_Iincome_5 | -.5425447 .0722025 -7.51 0.000 -.684059 -.4010303
_cons | -9.201724 .2266475 -40.60 0.000 -9.645945 -8.757503
-------------+----------------------------------------------------------------
/ln_p | .1585315 .0172241 9.20 0.000 .1247729 .1922901
-------------+----------------------------------------------------------------
p | 1.171789 .020183 1.132891 1.212022
1/p | .8533961 .014699 .8250675 .8826974
------------------------------------------------------------------------------

. * now get the hazard ratios where all coefs are raised to;


. * exp(b1);
. streg age_s_yrs black hispanic _Ie* _Ii*, d(weibull);

failure _d: diedin5


analysis time _t: max_mths

Fitting constant-only model:


Iteration 0: log likelihood = -12759.823


Iteration 1: log likelihood = -12723.121
Iteration 2: log likelihood = -12722.924
Iteration 3: log likelihood = -12722.924

Fitting full model:


Iteration 0: log likelihood = -12722.924


Iteration 1: log likelihood = -12454.553
Iteration 2: log likelihood = -12425.111
Iteration 3: log likelihood = -12425.055
Iteration 4: log likelihood = -12425.055

Weibull regression -- log relative-hazard form


No. of subjects = 26631 Number of obs = 26631


No. of failures = 3245
Time at risk = 1505705
LR chi2(10) = 595.74
Log likelihood = -12425.055 Prob > chi2 = 0.0000

------------------------------------------------------------------------------


_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age_s_yrs | 1.046299 .0033055 14.33 0.000 1.03984 1.052797
black | 1.611258 .082355 9.33 0.000 1.457667 1.781032
hispanic | 1.142656 .093876 1.62 0.105 .9727116 1.342291
_Ieduc_2 | 1.009379 .059747 0.16 0.875 .8988145 1.133544
_Ieduc_3 | .9303792 .0468103 -1.43 0.151 .8430114 1.026802
_Ieduc_4 | .8779924 .0576956 -1.98 0.048 .7718905 .9986788
_Iincome_2 | .8296302 .0539761 -2.87 0.004 .7303062 .9424625
_Iincome_3 | .7211611 .0496617 -4.75 0.000 .6301089 .8253706
_Iincome_4 | .5965372 .0458858 -6.72 0.000 .5130537 .6936049
_Iincome_5 | .5812672 .041969 -7.51 0.000 .5045648 .6696297
-------------+----------------------------------------------------------------
/ln_p | .1585315 .0172241 9.20 0.000 .1247729 .1922901
-------------+----------------------------------------------------------------
p | 1.171789 .020183 1.132891 1.212022
1/p | .8533961 .014699 .8250675 .8826974
------------------------------------------------------------------------------

. * for compairson purposes, look at results from an exponential;


. streg age_s_yrs black hispanic _Ie* _Ii*, d(exp) nohr;

failure _d: diedin5


analysis time _t: max_mths

Iteration 0: log likelihood = -12759.823


Iteration 1: log likelihood = -12493.913
Iteration 2: log likelihood = -12465.272
Iteration 3: log likelihood = -12465.218
Iteration 4: log likelihood = -12465.218

Exponential regression -- log relative-hazard form


No. of subjects = 26631 Number of obs = 26631


No. of failures = 3245
Time at risk = 1505705
LR chi2(10) = 589.21
Log likelihood = -12465.218 Prob > chi2 = 0.0000

------------------------------------------------------------------------------


_t | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age_s_yrs | .0450058 .0031587 14.25 0.000 .0388149 .0511968
black | .4739259 .0511077 9.27 0.000 .3737567 .574095
hispanic | .1325028 .0821549 1.61 0.107 -.0285178 .2935235
_Ieduc_2 | .0094567 .0591916 0.16 0.873 -.1065568 .1254701
_Ieduc_3 | -.071804 .0503096 -1.43 0.154 -.170409 .0268011
_Ieduc_4 | -.1293206 .0657092 -1.97 0.049 -.2581081 -.000533
_Iincome_2 | -.1855024 .0650573 -2.85 0.004 -.3130123 -.0579925
_Iincome_3 | -.3244382 .0688567 -4.71 0.000 -.4593948 -.1894816
_Iincome_4 | -.5134143 .0769126 -6.68 0.000 -.6641602 -.3626684
_Iincome_5 | -.5391811 .072196 -7.47 0.000 -.6806827 -.3976795
_cons | -8.491069 .2107085 -40.30 0.000 -8.90405 -8.078088
------------------------------------------------------------------------------

. streg age_s_yrs black hispanic _Ie* _Ii*, d(exp);


failure _d: diedin5


analysis time _t: max_mths

Iteration 0: log likelihood = -12759.823


Iteration 1: log likelihood = -12493.913
Iteration 2: log likelihood = -12465.272
Iteration 3: log likelihood = -12465.218
Iteration 4: log likelihood = -12465.218

Exponential regression -- log relative-hazard form


No. of subjects = 26631 Number of obs = 26631


No. of failures = 3245
Time at risk = 1505705
LR chi2(10) = 589.21
Log likelihood = -12465.218 Prob > chi2 = 0.0000

------------------------------------------------------------------------------


_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age_s_yrs | 1.046034 .0033041 14.25 0.000 1.039578 1.05253
black | 1.606288 .0820936 9.27 0.000 1.453184 1.775523
hispanic | 1.141682 .0937948 1.61 0.107 .971885 1.341145
_Ieduc_2 | 1.009502 .059754 0.16 0.873 .898924 1.133681
_Ieduc_3 | .9307133 .0468238 -1.43 0.154 .8433198 1.027163
_Ieduc_4 | .8786922 .0577381 -1.97 0.049 .7725117 .9994672
_Iincome_2 | .8306869 .0540422 -2.85 0.004 .731241 .943657
_Iincome_3 | .7229334 .0497788 -4.71 0.000 .6316658 .827388
_Iincome_4 | .5984488 .0460282 -6.68 0.000 .5147056 .6958171
_Iincome_5 | .5832257 .0421066 -7.47 0.000 .5062713 .6718773
------------------------------------------------------------------------------

. log close;


log: c:\bill\jpsm\surv_data.log
log type: text
closed on: 7 Nov 2004, 06:27:08
------------------------------------------------------------------------------





Download 230.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling