Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Fernando Rios Avila <f.rios.a@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Output of ML for Poisson vs. Stata Poisson Command |

Date |
Fri, 27 Jan 2012 12:51:36 -0500 |

HI I think the main reason is to constrain your lambda to be strictly positive, Since the expression EXP(LAMDA) is always positive, whereas LAMBDA can have any values. To compare between your two models, for instance u have to make the actual transformation in the second case: Lambda(model1) compare to Exp(lambda) model 2. You will see are exactly the same Fernando On Fri, Jan 27, 2012 at 12:29 PM, Gordon Burtch <gburtch@gmail.com> wrote: > Hello, > > I have hit a small wall trying to code the poisson estimator from scratch, using the ML command. I am estimating an intercept only model (i.e., ml model lf mypoisson (y=)). The intercept estimate that my custom code produces does not match the estimate produced by the stock STATA poisson command (i.e., poisson y). The issue here appears to be with my definition of the likelihood function. I am hoping someone can help me understand why. > > Here is my code... as I understand it, the likelihood function should just be the log of the poisson PDF (this is the same approach I took to code the Probit and Logit estimators, which worked correctly): > > program mypoisson > version 10.0 > args lnf lambda > quietly replace `lnf' = $ML_y1 * ln(`lambda') - `lambda' - lnfactorial($ML_y1) > end > > Upon discovering that this code produced an incorrect coefficient, I began scouring the Internet for a clue of what I might be doing wrong. I discovered that the correct estimate is obtained if I use exp(`lambda'), in place of `lambda'. I figured this out by looking at this code posted by Colin Cameron from UC Davis (http://cameron.econ.ucdavis.edu/stata/stmle.do). The output from each command is included at the end of this e-mail for reference. All commands are executed using the same count dataset. > > program mypoisson > version 10.0 > args lnf xB > local lambda = exp(`xB') > quietly replace `lnf' = $ML_y1 * ln(`lambda') - `lambda' - lnfactorial($ML_y1) > end > > So, why would one want to take the exponential of the lambda here, given that this does not fit with the derived likelihood function? Or have I missed something in my derivation? It had been suggested to me that taking the exponential might simply have to do with imposing a positive value constraint on lambda, however, since the coefficient output is actually changed by doing this, I am guessing this is not the reason. > > Thanks in advance for any assistance! > > Gord Burtch > Ph.D. Candidate, MIS > Fox School of Business > Temple University > Speakman Hall 201F > Philadelphia, PA, 19122 > Mob 215 688 3852 > > ========Stata Output Follows > > . ml model lf mypoisson (y=) > > . ml max > > initial: log likelihood = -<inf> (could not be evaluated) > feasible: log likelihood = -247.18569 > rescale: log likelihood = -169.83341 > Iteration 0: log likelihood = -169.83341 > Iteration 1: log likelihood = -166.57517 > Iteration 2: log likelihood = -166.37983 > Iteration 3: log likelihood = -166.37937 > Iteration 4: log likelihood = -166.37937 > > Number of obs = 100 > Wald chi2(0) = . > Log likelihood = -166.37937 Prob > chi2 = . > > ------------------------------------------------------------------------------ > y | Coef. Std. Err. z P>|z| [95% Conf. Interval] > -------------+---------------------------------------------------------------- > _cons | 1.64 .1280625 12.81 0.000 1.389002 1.890998 > ------------------------------------------------------------------------------ > > . poisson y > > Iteration 0: log likelihood = -166.37937 > Iteration 1: log likelihood = -166.37937 > > Poisson regression Number of obs = 100 > LR chi2(0) = -0.00 > Prob > chi2 = . > Log likelihood = -166.37937 Pseudo R2 = -0.0000 > > ------------------------------------------------------------------------------ > y | Coef. Std. Err. z P>|z| [95% Conf. Interval] > -------------+---------------------------------------------------------------- > _cons | .4946962 .0780869 6.34 0.000 .3416488 .6477437 > ------------------------------------------------------------------------------ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Output of ML for Poisson vs. Stata Poisson Command***From:*Gordon Burtch <gburtch@gmail.com>

**References**:**st: Output of ML for Poisson vs. Stata Poisson Command***From:*Gordon Burtch <gburtch@gmail.com>

- Prev by Date:
**Re: st: general-to-specific GETS algorithm** - Next by Date:
**RE: st: Arellano-Bond test for AR(2) in first differences after xtivreg2** - Previous by thread:
**st: Output of ML for Poisson vs. Stata Poisson Command** - Next by thread:
**Re: st: Output of ML for Poisson vs. Stata Poisson Command** - Index(es):