Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Matthew J Baker <matthew.baker@hunter.cuny.edu> |
To | statalist@hsphsun2.harvard.edu |
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: owner-statalist@hsphsun2.harvard.edu (on behalf of Alfonso Miranda <A.Miranda@ioe.ac.uk>) >Subject: Re: st: mle stata program >To: Statalist <statalist@hsphsun2.harvard.edu> > >Dear Jian, > >What is $ML_y2^2? Do you have more than one equation? > >Best, > >Alfonso. > > >On 07/03/2011 15:23, "Jian Zhang" <jian32@gmail.com> 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/