* exercise 5.3 of Greene's textbook, edition 4, page 208-209 * input the data use 53_poisson.dta, clear capture program drop mle_poisson program define mle_poisson version 8.0 args lnf theta1 quietly replace `lnf'=-exp(`theta1')+$ML_y1*(`theta1')-lngamma($ML_y1+1) end ml model lf mle_poisson (y=x) ml maximize capture program drop mle_poisson1 program define mle_poisson1 version 8.0 args lnf theta1 quietly replace `lnf'=-exp(`theta1')+$ML_y1*(`theta1') end ml model lf mle_poisson1 (y=x) ml maximize /* y x 6 1.5 7 1.8 4 1.8 10 2 10 1.3 6 1.6 4 1.2 7 1.9 2 1.8 3 1 6 1.4 5 .5 3 .8 3 1.1 4 .7 . do "C:\Documents and Settings\jlee\My Documents\EC671\53_poisson.do" . . * exercise 5.3 of Greene's textbook, edition 4, page 208-209 . * input the data . . use 53_poisson.dta, clear . . capture program drop mle_poisson . program define mle_poisson 1. version 8.0 2. args lnf theta1 3. quietly replace `lnf'=-exp(`theta1')+$ML_y1*(`theta1')-lngamma($ML_y1+1) 4. end . . ml model lf mle_poisson (y=x) . ml maximize initial: log likelihood = -102.38698 alternative: log likelihood = -72.117799 rescale: log likelihood = -38.222822 Iteration 0: log likelihood = -38.222822 Iteration 1: log likelihood = -32.137797 Iteration 2: log likelihood = -32.066088 Iteration 3: log likelihood = -32.066011 Iteration 4: log likelihood = -32.066011 Number of obs = 15 Wald chi2(1) = 2.72 Log likelihood = -32.066011 Prob > chi2 = 0.0993 ------------------------------------------------------------------------------ y | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .4248897 .2578109 1.65 0.099 -.0804104 .9301898 _cons | 1.078078 .3886433 2.77 0.006 .3163506 1.839805 ------------------------------------------------------------------------------ . capture program drop mle_poisson1 . . program define mle_poisson1 1. version 8.0 2. args lnf theta1 3. quietly replace `lnf'=-exp(`theta1')+$ML_y1*(`theta1') 4. end . . ml model lf mle_poisson1 (y=x) . ml maximize initial: log likelihood = -15 alternative: log likelihood = 15.269181 rescale: log likelihood = 49.164159 Iteration 0: log likelihood = 49.164159 Iteration 1: log likelihood = 55.254407 Iteration 2: log likelihood = 55.320936 Iteration 3: log likelihood = 55.32097 Iteration 4: log likelihood = 55.32097 Number of obs = 15 Wald chi2(1) = 2.72 Log likelihood = 55.32097 Prob > chi2 = 0.0993 ------------------------------------------------------------------------------ y | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .4248897 .2578109 1.65 0.099 -.0804104 .9301898 _cons | 1.078078 .3886433 2.77 0.006 .3163506 1.839805 ------------------------------------------------------------------------------ . end of do-file */