Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: Output of ML for Poisson vs. Stata Poisson Command


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: Output of ML for Poisson vs. Stata Poisson Command
Date   Fri, 27 Jan 2012 18:39:49 +0000

However, although that would lead to a literal answer to the last question, it is not what you are seeking. -constraint- in Stata means linear constraint, and inequalities don't qualify, which is why transformations are recommended when the parameter is necessarily bounded above and/or below. 

Nick 
[email protected] 


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 27 January 2012 18:31
To: '[email protected]'
Subject: RE: st: Output of ML for Poisson vs. Stata Poisson Command

See the help for -ml-. 

Nick 
[email protected] 

Gordon Burtch

Thanks for clarifying! I'm just curious, is there a way to constrain parameters without using transformations (a way that is more explicit and intuitive)? 

On 2012-01-27, at 12:51 PM, Fernando Rios Avila wrote:

> 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
 
On Fri, Jan 27, 2012 at 12:29 PM, Gordon Burtch <[email protected]> wrote:
 
>> 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.
> 
 

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index