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: mle stata program


From   Jian Zhang <[email protected]>
To   [email protected]
Subject   Re: st: mle stata program
Date   Tue, 8 Mar 2011 10:47:41 +0800

there is actually only one equation.  The ml model is:  ml model lf
myml (Y = x q r) /theta /sigma

x, q and r are the set of independent variables (i.e., Z).  The
complicated thing is that x, as one individual independent variable,
enters the log likelihood function by itself, appearing in the log
likelihood function as: (xi^2* theta^2 + sigma^2).  In the program, I
use $ML_y2 to indicate x.

Anything wrong?  thanks

Jian

On Tue, Mar 8, 2011 at 3:54 AM, Matthew J Baker
<[email protected]> wrote:
> I can't find anything wrong with the program, but I am a little
> confused as to why "w" is introduced as a variable and then
> replaced. Might it be better to do something like:
>
> program myml
> version 9.2
> args lnf xb theta sigma
> tempvar w
> quietly {
> gen double `w'=$ML_y2^2*`theta'^2+`sigma'^2
> replace `lnf'=-0.5 * ln(`w')-0.5*($ML_y1-`xb')/`w'
> }
> end
>
> Also, what does the corresponding ml model statement look like
> for the program?
>
> Best regards,
>
> Matt Baker
>
> Dr. Matthew J. Baker
> Department of Economics
> Hunter College and the Graduate Center, CUNY
>
> ---- Original message ----
>>Date: Mon, 7 Mar 2011 15:35:23 +0000
>>From: [email protected] (on behalf of
> Alfonso Miranda <[email protected]>)
>>Subject: Re: st: mle stata program
>>To: Statalist <[email protected]>
>>
>>Dear Jian,
>>
>>What is $ML_y2^2? Do you have more than one equation?
>>
>>Best,
>>
>>Alfonso.
>>
>>
>>On 07/03/2011 15:23, "Jian Zhang" <[email protected]>
> wrote:
>>
>>> Hello all,
>>>
>>> below is the loglikelihood function i'd like to maximize with
> stata.
>>> I wrote some program but it did not work. Could some one
> give me some
>>> help?
>>>
>>> the log likelihood function for the ith observation: lnYi=-0.5 *
>>> ln(2pi) - 0.5ln(xi^2* theta^2 + sigma^2) -0.5 (lnYi - Beta*
> Zi)^2
>>> /(xi^2* theta^2 + sigma^2), where Yi is the dependent
> variable, Zi is
>>> the set of independent variables and xi is ONE independent
> variable
>>> from the set Zi.  pi, theta and sigma are the parameters to
> be
>>> estimated via ml
>>>
>>> Corresponding to the log likelihood function is the program I
> wrote:
>>>
>>> program myml
>>> version 9.2
>>> args lnf xb w theta sigma
>>> quietly {
>>> replace `w'=$ML_y2^2*`theta'^2+`sigma'^2
>>> replace `lnf'=-0.5 * ln(`w')-0.5*($ML_y1-`xb')/`w'
>>> }
>>> end
>>>
>>> But Stata said the program does not work.  Is there
> something wrong
>>> with the program?
>>>
>>> Many thanks!
>>>
>>> Jian
>>>
>>> *
>>> *   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/
>
> *
> *   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