Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Arguments in the -ml-


From   "Mentzakis, Emmanouil" <e.mentzakis@abdn.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Arguments in the -ml-
Date   Fri, 1 Feb 2008 11:41:26 -0000

Maarten, thank you for the reply. 
 
I ve extended your example a little bit.  
 
-mynormal_lf1- is the one you set and   
-mynormal_lf2- is the same one but reversing the order in which the arguments appear in the -lnf-,   
-mynormal_lf3- is the same but reversing the arguments in -args- and    
-mynormal_lf4- has everything reversed.     
 
Every dyad of models gives the same results which shows that all the orders matter at the end of the day. 
 
So, the order in -args- should follow the order in -lnf-  which should follow the order in -ml model-. Would this be a foolproof procedure to follow? 
 
This is a very simple LogL (and verifiable against an official command) so the problem is not apparent but sometimes things can be a bit more messy.
 
Any suggestions are wellcome.
 
Thank you
Manos

*-------------- begin example -----------------------
sysuse auto, clear   
capture program drop mynormal_lf1
program mynormal_lf1
        version 8.1
        args lnf mu sigma
        quietly replace `lnf' = ln(normden($ML_y1,`mu', `sigma'))
end     
    
sysuse auto, clear    
capture program drop mynormal_lf2
program mynormal_lf2
        version 8.1
        args lnf mu sigma 
        quietly replace `lnf' = ln(normden($ML_y1,`sigma', `mu'))
end       
    
sysuse auto, clear   
capture program drop mynormal_lf3
program mynormal_lf3
        version 8.1
        args lnf sigma mu 
        quietly replace `lnf' = ln(normden($ML_y1,`mu',`sigma'))
end        
 
sysuse auto, clear   
capture program drop mynormal_lf4
program mynormal_lf4
        version 8.1
        args lnf sigma mu 
        quietly replace `lnf' = ln(normden($ML_y1,`sigma',`mu'))
end       
   

ml model lf mynormal_lf1 (mpg = weight displacement) ()    
ml maximize, nolog    
ml model lf mynormal_lf4 (mpg = weight displacement) ()    
ml maximize, nolog   

ml model lf mynormal_lf2 () (mpg = weight displacement)   
ml maximize,nolog   
ml model lf mynormal_lf3 () (mpg = weight displacement)   
ml maximize,nolog   

***

ml model lf mynormal_lf1 () (mpg = weight displacement)  
ml maximize,nolog   
ml model lf mynormal_lf4 () (mpg = weight displacement)  
ml maximize,nolog  

ml model lf mynormal_lf2 (mpg = weight displacement) ()  
ml maximize, nolog   
ml model lf mynormal_lf3 (mpg = weight displacement) ()    
ml maximize, nolog  

exit

*-------------------- end example --------------------------------



________________________________

From: owner-statalist@hsphsun2.harvard.edu on behalf of Maarten buis
Sent: Fri 2/1/2008 10:25 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Arguments in the -ml-



--- "Mentzakis, Emmanouil" <e.mentzakis@abdn.ac.uk> wrote:
> When estimating a LogL function with -ml-, e.g.
>
> program test
>   version 9.1
>   args lnf xb theta1
>       qui replace `lnf' = ln(...) if $ML_y1 == 1
>       qui replace `lnf' = ln(...) if $ML_y1 == 2
>        .
>        .
>        .
> end
>
> ml model lf test (y= ) / theta1
> ml maximize
>
> How does Stata know that -xb- corresponds to the first equation and
> -theta1- to the second?
>
> Should the order that the arguments appear in -args- be the same as
> the order they appear in the LogL?

I had a quick look around and I did not find an explicit statement of
that. Though by its very nature the use of the -args- command suggests
that it is the order in which the equations appear in the -ml model-
command (see: -help args-). This is confirmed by the quick experiment
below:

*-------------- begin example -----------------------
sysuse auto, clear
capture program drop mynormal_lf
program mynormal_lf
        version 8.1
        args lnf mu sigma
        quietly replace `lnf' = ln(normden($ML_y1, `mu', `sigma'))
end

ml model lf mynormal_lf (mpg = weight displacement) ()
ml search
ml maximize
ml model lf mynormal_lf () (mpg = weight displacement)
ml search
ml maximize

exit
*-------------------- end example --------------------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________
Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


<<winmail.dat>>




© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index