* Poisson regression (Ex. 5.3, Greene, p. 208) input id y x 1 6 1.5 2 7 1.8 3 4 1.8 4 10 2.0 5 10 1.3 6 6 1.6 7 4 1.2 8 7 1.9 9 2 1.8 10 3 1.0 11 6 1.4 12 5 0.5 13 3 0.8 14 3 1.1 15 4 0.7 end list * Poisson regression; poisson y x * Poisson MLE *clear *insheet using poisson_data.txt log using poisson_output.log, replace /* this is the "canned" routine that estimates the poisson regression */ poisson y x /* this maximizes lnL directly, using logged factorial of y */ program define poisreg1 args lnf theta quietly replace `lnf' = -exp(`theta') + $ML_y1*(`theta') - lnfact($ML_y1) end ml model lf poisreg1 (y=x) ml maximize /* this maximizes lnL directly, using the logged gamma function */ program define poisreg2 version 8 args lnf theta quietly replace `lnf' = -exp(`theta') + $ML_y1*(`theta') - lngamma($ML_y1 + 1) end ml model lf poisreg2 (y=x) ml maximize