Stata program for Probit/Logit Models


STATA Program for Count Data Models


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

STATA Program for Count Data Models
drvisits.do

* drvisits.do;


* this program estimates a poisson and negative binomial;
* count data model. teh data inclused people aged 65+;
* from the 1987 nmes data set. dr visits are annual;

* this line defines the semicolon as the line delimiter;


# delimit ;

* set memork for 10 meg;


set memory 10m;

* open output file;


log using c:\bill\jpsm\drvisits.log,replace;

* open stata data set;


use c:\bill\jpsm\drvisits;

* generate new variables;


gen incomel=ln(income);

* get distribution of dr visits;


tabulate drvisits;

* get descriptive statistics;


sum;
* run poisson regression;
poisson drvisits age65 age70 age75 age80 chronic excel good fair female
black hispanic hs_drop hs_grad mcaid incomel;
* run neg binomial regression;
nbreg drvisits age65 age70 age75 age80 chronic excel good fair female
black hispanic hs_drop hs_grad mcaid incomel, dispersion(constant);

log close;




STATA Results for Count Data Models
drvisits.log

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


log: C:\bill\stata\drvisits.log
log type: text
opened on: 28 Oct 2004, 13:44:05

. * open stata data set;


. use drvisits;

. * generate new variables;


. gen incomel=ln(income);
(28 missing values generated)

. * get distribution of dr visits;


. tabulate drvisits;

annual doc |


visits | Freq. Percent Cum.
------------+-----------------------------------
0 | 915 17.18 17.18
1 | 601 11.28 28.46
2 | 533 10.01 38.46
3 | 503 9.44 47.91
4 | 450 8.45 56.35
5 | 391 7.34 63.69
6 | 319 5.99 69.68
7 | 258 4.84 74.53
8 | 216 4.05 78.58
9 | 192 3.60 82.19
10 | 147 2.76 84.94
11 | 123 2.31 87.25
12 | 99 1.86 89.11
13 | 81 1.52 90.63
14 | 80 1.50 92.13
15 | 66 1.24 93.37
16 | 56 1.05 94.42
17 | 56 1.05 95.48
18 | 34 0.64 96.11
19 | 26 0.49 96.60
20 | 17 0.32 96.92
21 | 21 0.39 97.32
22 | 20 0.38 97.69
23 | 11 0.21 97.90
24 | 15 0.28 98.18
25 | 4 0.08 98.25
26 | 12 0.23 98.48
27 | 9 0.17 98.65
28 | 6 0.11 98.76
29 | 4 0.08 98.84
30 | 5 0.09 98.93
31 | 6 0.11 99.04
32 | 2 0.04 99.08
33 | 2 0.04 99.12
34 | 3 0.06 99.17
35 | 2 0.04 99.21
36 | 2 0.04 99.25
37 | 4 0.08 99.32
38 | 2 0.04 99.36
39 | 5 0.09 99.46
40 | 2 0.04 99.49
41 | 1 0.02 99.51
42 | 4 0.08 99.59
43 | 2 0.04 99.62
44 | 2 0.04 99.66
47 | 1 0.02 99.68
48 | 2 0.04 99.72
49 | 1 0.02 99.74
50 | 1 0.02 99.76
51 | 1 0.02 99.77
53 | 2 0.04 99.81
55 | 1 0.02 99.83
56 | 1 0.02 99.85
58 | 2 0.04 99.89
61 | 1 0.02 99.91
63 | 1 0.02 99.92
65 | 1 0.02 99.94
66 | 1 0.02 99.96
68 | 1 0.02 99.98
89 | 1 0.02 100.00
------------+-----------------------------------
Total | 5,327 100.00

. * get descriptive statistics;


. sum;

Variable | Obs Mean Std. Dev. Min Max


-------------+--------------------------------------------------------
drvisits | 5327 5.563732 6.676081 0 89
age65 | 5327 .3358363 .4723263 0 1
age70 | 5327 .2802703 .4491734 0 1
age75 | 5327 .2003004 .4002627 0 1
age80 | 5327 .1101934 .31316 0 1
-------------+--------------------------------------------------------
chronic | 5327 .6279332 .4834015 0 1
excel | 5327 .0749014 .263257 0 1
good | 5327 .3792003 .4852336 0 1
fair | 5327 .3305801 .4704662 0 1
hs_drop | 5327 .5029097 .5000385 0 1
-------------+--------------------------------------------------------
hs_grad | 5327 .2922846 .4548551 0 1
black | 5327 .1255866 .331414 0 1
hispanic | 5327 .0324761 .1772774 0 1
female | 5327 .5969589 .4905549 0 1
mcaid | 5327 .1019335 .3025893 0 1
-------------+--------------------------------------------------------
income | 5327 25381.78 28962.69 0 548224
incomel | 5299 9.754733 .8911269 2.639057 13.21444

. * run poisson regression;


. poisson drvisits age65 age70 age75 age80 chronic excel good fair female
> black hispanic hs_drop hs_grad mcaid incomel;

Iteration 0: log likelihood = -22275.374


Iteration 1: log likelihood = -22275.351
Iteration 2: log likelihood = -22275.351

Poisson regression Number of obs = 5299


LR chi2(15) = 3334.46
Prob > chi2 = 0.0000
Log likelihood = -22275.351 Pseudo R2 = 0.0696

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


drvisits | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age65 | .2144282 .026267 8.16 0.000 .1629458 .2659106
age70 | .286831 .0263077 10.90 0.000 .2352689 .3383931
age75 | .2801504 .0269802 10.38 0.000 .2272702 .3330307
age80 | .24314 .0292045 8.33 0.000 .1859001 .3003798
chronic | .4997173 .0137789 36.27 0.000 .4727111 .5267235
excel | -.7836622 .0305392 -25.66 0.000 -.8435178 -.7238065
good | -.4774853 .0159987 -29.85 0.000 -.5088422 -.4461284
fair | -.2578352 .0155473 -16.58 0.000 -.2883073 -.2273631
female | .0960976 .0123182 7.80 0.000 .0719543 .1202409
black | -.2838081 .0202163 -14.04 0.000 -.3234314 -.2441849
hispanic | -.2051023 .0368764 -5.56 0.000 -.2773788 -.1328258
hs_drop | -.2323802 .016066 -14.46 0.000 -.263869 -.2008914
hs_grad | -.1200559 .016517 -7.27 0.000 -.1524287 -.0876831
mcaid | .1535708 .0203414 7.55 0.000 .1137025 .1934392
incomel | .0211453 .0072946 2.90 0.004 .0068481 .0354425
_cons | 1.348084 .0804659 16.75 0.000 1.190374 1.505795
------------------------------------------------------------------------------

. * run neg binomial regression;


. nbreg drvisits age65 age70 age75 age80 chronic excel good fair female
> black hispanic hs_drop hs_grad mcaid incomel, dispersion(constant);

Fitting Poisson model:


Iteration 0: log likelihood = -22275.374


Iteration 1: log likelihood = -22275.351
Iteration 2: log likelihood = -22275.351

Fitting constant-only model:


Iteration 0: log likelihood = -17434.216


Iteration 1: log likelihood = -15076.44
Iteration 2: log likelihood = -14841.425
Iteration 3: log likelihood = -14840.935
Iteration 4: log likelihood = -14840.935

Fitting full model:


Iteration 0: log likelihood = -14840.935


Iteration 1: log likelihood = -14540.408
Iteration 2: log likelihood = -14519.799
Iteration 3: log likelihood = -14519.721
Iteration 4: log likelihood = -14519.721

Negative binomial (constant dispersion) Number of obs = 5299


LR chi2(15) = 642.43
Prob > chi2 = 0.0000
Log likelihood = -14519.721 Pseudo R2 = 0.0216

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


drvisits | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age65 | .1034281 .054664 1.89 0.058 -.0037113 .2105675
age70 | .2039634 .0546788 3.73 0.000 .0967949 .3111319
age75 | .2094928 .0560412 3.74 0.000 .0996541 .3193314
age80 | .2227169 .0605925 3.68 0.000 .1039579 .341476
chronic | .5091666 .0292189 17.43 0.000 .4518986 .5664347
excel | -.5272908 .0594584 -8.87 0.000 -.6438271 -.4107545
good | -.3422506 .0353507 -9.68 0.000 -.4115368 -.2729645
fair | -.1526385 .0351632 -4.34 0.000 -.2215571 -.0837198
female | .1321966 .0263028 5.03 0.000 .0806441 .183749
black | -.3300031 .0438969 -7.52 0.000 -.4160395 -.2439668
hispanic | -.1527763 .0763018 -2.00 0.045 -.3023251 -.0032275
hs_drop | -.1912903 .0344335 -5.56 0.000 -.2587787 -.1238018
hs_grad | -.0869843 .0354543 -2.45 0.014 -.1564733 -.0174952
mcaid | .1341325 .0442797 3.03 0.002 .0473459 .2209191
incomel | .0379834 .0155687 2.44 0.015 .0074693 .0684975
_cons | 1.11029 .17092 6.50 0.000 .7752924 1.445287
-------------+----------------------------------------------------------------
/lndelta | 1.65017 .0286445 1.594027 1.706312
-------------+----------------------------------------------------------------
delta | 5.207863 .1491766 4.923538 5.508607
------------------------------------------------------------------------------
Likelihood-ratio test of delta=0: chibar2(01) = 1.6e+04 Prob>=chibar2 = 0.000

. log close;


log: C:\bill\stata\drvisits.log
log type: text
closed on: 28 Oct 2004, 13:44:20
------------------------------------------------------------------------------

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