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   Matthew J Baker <[email protected]>
To   [email protected]
Subject   Re: st: mle stata program
Date   Mon, 7 Mar 2011 14:54:49 -0500 (EST)

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/


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