. . * This STATA program reads in data and gives summary statistics and Poisson a > nd . * negative binomial models for the office visits to physician data studied in . * Chapter 6.3 of . * A.C. Cameron and Pravin K. Trivedi (1998), . * REGRESSION ANALYSIS OF COUNT DATA, . * Econometric Society Monograph No.30, Cambridge University Press. . . * The program does only a small part of the analysis in the book. . . * To run you need file . * racd6d1.asc . * in your directory . . ********** DATA DESCRIPTION . * . * The data are extracted from the 1987-88 National Medical Expenditure Survey > (NMES). . * The extract and analysis are in P. Deb and P.K. Trivedi (1997), . * Demand for Medical Care by the Elderly: A Finite Mixture Approach" . * Journal of Applied Econometrics, 12, 313-326. . . * See Table 6.2 p.194 of Cameron and Trivedi (1998) for variable descriptions . * 1. ofp . * 2. ofnp . * 3. opp . * 4. opnp . * 5. emr . * 6. hosp . * 7. exclhlth . * 8. poorhlth . * 9. numchron . * 10. adldiff . * 11. noreast . * 12. midwest . * 13. west . * 14. age . * 15. black . * 16. male . * 17. married . * 18. school . * 19. faminc . * 20. employed . * 21. privins . * 22. medicaid . . ********** CREATE OUTPUT FILE . * . di "racd6p1.do for Cameron and Trivedi RACD chapters 6.3" racd6p1.do for Cameron and Trivedi RACD chapters 6.3 . . ********** READ DATA . * . * The Physician office visits data are in ascii file racd6d1.asc . * There are 4406 observations on 22 variables with one lines per obs . * The data are free format separated by blanks . . infile ofp ofnp opp opnp emr hosp exclhlth poorhlth numchron adldiff noreast > /* > */ midwest west age black male married school faminc employed privins /* > */ medicaid using racd6d1.asc (4406 observations read) . . ********** DATA TRANSFORMATIONS . * . . ******** CHECK DATA: DESCRIPTIVE STATISTICS . * . describe Contains data obs: 4,406 vars: 22 size: 405,352 (60.4% of memory free) ------------------------------------------------------------------------------- 1. ofp float %9.0g 2. ofnp float %9.0g 3. opp float %9.0g 4. opnp float %9.0g 5. emr float %9.0g 6. hosp float %9.0g 7. exclhlth float %9.0g 8. poorhlth float %9.0g 9. numchron float %9.0g 10. adldiff float %9.0g 11. noreast float %9.0g 12. midwest float %9.0g 13. west float %9.0g 14. age float %9.0g 15. black float %9.0g 16. male float %9.0g 17. married float %9.0g 18. school float %9.0g 19. faminc float %9.0g 20. employed float %9.0g 21. privins float %9.0g 22. medicaid float %9.0g ------------------------------------------------------------------------------- Sorted by: Note: dataset has changed since last saved . summarize Variable | Obs Mean Std. Dev. Min Max ---------+----------------------------------------------------- ofp | 4406 5.774399 6.759225 0 89 ofnp | 4406 1.618021 5.317056 0 104 opp | 4406 .7507944 3.652759 0 141 opnp | 4406 .5360872 3.879506 0 155 emr | 4406 .2635043 .7036586 0 12 hosp | 4406 .2959601 .7463978 0 8 exclhlth | 4406 .0778484 .2679633 0 1 poorhlth | 4406 .1257376 .3315911 0 1 numchron | 4406 1.541988 1.349632 0 8 adldiff | 4406 .2040399 .4030441 0 1 noreast | 4406 .1899682 .3923203 0 1 midwest | 4406 .2625965 .4400949 0 1 west | 4406 .1811167 .3851585 0 1 age | 4406 7.402406 .6334051 6.6 10.9 black | 4406 .117113 .3215914 0 1 male | 4406 .4035406 .4906631 0 1 married | 4406 .5460735 .4979292 0 1 school | 4406 10.29029 3.738736 0 18 faminc | 4406 2.527132 2.924648 -1.0125 54.8351 employed | 4406 .1032683 .3043435 0 1 privins | 4406 .7764412 .4166769 0 1 medicaid | 4406 .0912392 .2879817 0 1 . . ******** SAVE DATA AS STATA DATA SET . * . * save racd6d1, replace . . . ********** POISSON REGRESSION . * . poisson ofp exclhlth poorhlth numchron adldiff noreast midwest west age black > /* > */ male married school faminc employed privins medicaid Iteration 0: log likelihood = -18134.655 Iteration 1: log likelihood = -18134.567 Iteration 2: log likelihood = -18134.567 Poisson regression Number of obs = 4406 LR chi2(16) = 3449.21 Prob > chi2 = 0.0000 Log likelihood = -18134.567 Pseudo R2 = 0.0868 ------------------------------------------------------------------------------ ofp | Coef. Std. Err. z P>|z| [95% Conf. Interval] ---------+-------------------------------------------------------------------- exclhlth | -.3862208 .0304497 -12.684 0.000 -.445901 -.3265405 poorhlth | .2873922 .0182529 15.745 0.000 .2516172 .3231672 numchron | .1639607 .0045507 36.030 0.000 .1550416 .1728799 adldiff | .0934088 .0166728 5.602 0.000 .0607307 .126087 noreast | .1075677 .0177083 6.074 0.000 .0728601 .1422752 midwest | -.0105486 .0167555 -0.630 0.529 -.0433888 .0222916 west | .1238461 .0180369 6.866 0.000 .0884944 .1591978 age | -.0552906 .0108588 -5.092 0.000 -.0765735 -.0340076 black | -.0655474 .0224742 -2.917 0.004 -.1095961 -.0214987 male | -.0713668 .0142989 -4.991 0.000 -.0993921 -.0433415 married | -.0407636 .0147648 -2.761 0.006 -.0697022 -.0118251 school | .0258206 .0019561 13.200 0.000 .0219867 .0296545 faminc | -.0023524 .002302 -1.022 0.307 -.0068642 .0021594 employed | .0527792 .0220024 2.399 0.016 .0096553 .0959031 privins | .321541 .0196505 16.363 0.000 .2830268 .3600553 medicaid | .2886599 .0250746 11.512 0.000 .2395146 .3378051 _cons | 1.296604 .087377 14.839 0.000 1.125349 1.46786 ------------------------------------------------------------------------------ . nbreg ofp exclhlth poorhlth numchron adldiff noreast midwest west age black / > * > */ male married school faminc employed privins medicaid Fitting comparison Poisson model: Iteration 0: log likelihood = -18134.655 Iteration 1: log likelihood = -18134.567 Iteration 2: log likelihood = -18134.567 Fitting constant-only model: Iteration 0: log likelihood = -12492.848 Iteration 1: log likelihood = -12492.829 Iteration 2: log likelihood = -12492.829 Fitting full model: Iteration 0: log likelihood = -12225.401 Iteration 1: log likelihood = -12202.265 Iteration 2: log likelihood = -12202.168 Iteration 3: log likelihood = -12202.168 Negative binomial regression Number of obs = 4406 LR chi2(16) = 581.32 Prob > chi2 = 0.0000 Log likelihood = -12202.168 Pseudo R2 = 0.0233 ------------------------------------------------------------------------------ ofp | Coef. Std. Err. z P>|z| [95% Conf. Interval] ---------+-------------------------------------------------------------------- exclhlth | -.3845559 .0616412 -6.239 0.000 -.5053703 -.2637414 poorhlth | .3226979 .0497273 6.489 0.000 .2252341 .4201616 numchron | .1897393 .0125582 15.109 0.000 .1651257 .214353 adldiff | .0967679 .0422561 2.290 0.022 .0139475 .1795883 noreast | .1112554 .0438561 2.537 0.011 .0252991 .1972117 midwest | -.0011415 .0403674 -0.028 0.977 -.0802602 .0779772 west | .1368204 .0453527 3.017 0.003 .0479307 .2257101 age | -.0356419 .0269603 -1.322 0.186 -.088483 .0171993 black | -.0661781 .0528737 -1.252 0.211 -.1698086 .0374523 male | -.0750747 .0352575 -2.129 0.033 -.1441782 -.0059711 married | -.0355703 .0367964 -0.967 0.334 -.1076899 .0365494 school | .0273927 .0046247 5.923 0.000 .0183285 .0364568 faminc | -.0016692 .0056213 -0.297 0.767 -.0126867 .0093483 employed | .0255672 .0526905 0.485 0.628 -.0777043 .1288387 privins | .3458812 .0460978 7.503 0.000 .2555312 .4362313 medicaid | .2761625 .0645046 4.281 0.000 .1497358 .4025891 _cons | 1.05945 .2159755 4.905 0.000 .6361456 1.482754 ---------+-------------------------------------------------------------------- /lnalpha | -.1674191 .0276127 -6.063 0.000 -.2215391 -.1132992 ---------+-------------------------------------------------------------------- alpha | .845845 .0233561 .8012846 .8928835 ------------------------------------------------------------------------------ Likelihood ratio test of alpha=0: chi2(1) = 11864.80 Prob > chi2 = 0.0000 . . ********** CLOSE OUTPUT . log close