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

Re: st: RE: -by- in ML


From   watt@fas.harvard.edu
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: -by- in ML
Date   Mon, 6 Jun 2005 18:05:41 -0400

John,

Thanks for the quick reply. I should probably elaborate.

The data is already sorted by "us_id". The ML command actually does not give me
any error. What happens is that it tells me the log likelihood is always 0.
Thus, I know there's a problem.

Thanks in advance.

Stanley


Quoting "Wallace, John" <John_Wallace@affymetrix.com>:

> Your example doesn't explictly contain a -sort- command for your
> variable "us_id", which might be the problem.  -By:- needs to have the
> dataset sorted, you can do this on the fly by replacing it with
> -bysort:-. To get more information from Stata, you might try using the
> -capture- command to trap the error code that would have been returned
> in interactive mode.
>
> Hope this helps
> -John W
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of
> watt@fas.harvard.edu
> Sent: Monday, June 06, 2005 2:31 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: -by- in ML
>
> Here is my code:
>
> program mylogit2
> 	version 8.0
> 	args todo b lnf
> 	tempvar theta1 a c group_sum last
> 	mleval `theta1' = `b', eq(1)
> 	quietly gen double `a' = exp(`theta1')/(1+exp(`theta1'))
> 	quietly gen double `c' =  1/(1+exp(`theta1'))
> 	by us_id: gen double `group_sum' = sum(ln(`a'^($ML_y1) *
> `c'^(1-$ML_y1)))
> 	by us_id: gen double `last' = (_n==_N)
> 	mlsum `lnf' = `group_sum' if `last'
> end
>
> ml model d0 mylogit2 (y = x1 x2)
> ml check
> ml search
> ml maximize
>
> *
> *   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/
>




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