Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Maximum-likelihood estimation


From   "Renzo Comolli" <renzo.comolli@yale.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Maximum-likelihood estimation
Date   Tue, 3 Feb 2004 00:57:43 -0500

It works wonders for me. I don't know what to say.
I suggest you try -update query- given that the -ml- changed in version 8.1
although I doubt it will make any difference since nothing of what you use
here as changed since version 8

. use http://www.stata-press.com/data/r8/auto.dta, clear
(1978 Automobile Data)

. capture program drop mylogit

. program define mylogit
  1.    args lnf Xb
  2.    replace `lnf' = -ln(1+exp(-`Xb')) if $ML_y1==1
  3.    replace `lnf' = -`Xb' -ln(1+exp(-`Xb')) if $ML_y==0
  4. end

. ml model lf mylogit (foreign=mpg weight)

. ml maximize

(22 real changes made)
(52 real changes made)
initial:       log likelihood = -51.292891
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
alternative:   log likelihood = -46.081697
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
rescale:       log likelihood = -45.181365
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
Iteration 0:   log likelihood = -45.181365  
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
Iteration 1:   log likelihood = -29.420506  
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
Iteration 2:   log likelihood = -27.220547  
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
Iteration 3:   log likelihood = -27.175237  
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
Iteration 4:   log likelihood = -27.175156  
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
(22 real changes made)
(52 real changes made)
Iteration 5:   log likelihood = -27.175156  

                                                  Number of obs   =
74
                                                  Wald chi2(2)    =
17.78
Log likelihood = -27.175156                       Prob > chi2     =
0.0001

----------------------------------------------------------------------------
--
     foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
         mpg |  -.1685869   .0919175    -1.83   0.067    -.3487418
.011568
      weight |  -.0039067   .0010116    -3.86   0.000    -.0058894
-.001924
       _cons |   13.70837   4.518709     3.03   0.002     4.851859
22.56487
----------------------------------------------------------------------------
--



----------------------------------------------------------------------------
----
*From   David Greenberg <dg4@nyu.edu> 
To   statalist@hsphsun2.harvard.edu 
Subject   st: Maximum-likelihood estimation 
Date   Mon, 02 Feb 2004 20:05:51 -0500 

----------------------------------------------------------------------------
----

I am trying to learn the maximum-likelihood procedure in  Stata SE version
8, but am getting error messages when following illustrative examples, one
from someone's web site, the other from the Stata manual. Perhaps someone
can tell me what I'm doing wrong.
   Here is the first example:
use http://www.stata-press.com/data/r8/auto.dta
program define mylogit
   args lnf Xb
   replace `lnf' = -ln(1+exp(-`Xb')) if $ML_y1==1
   replace `lnf' = -`Xb' -ln(1+exp(-`Xb')) if $ML_y==0
end
ml model lf mylogit (foreign=mpg weight)
ml maximize
    At this point I get the message 
 varlist required
 (r100);
What do I need to do to fix the syntax?  
                   Thanx,
                      David Greenberg
                      Sociology Department
                      New York University




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



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