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

st: RE: -by- in ML

From   "Wallace, John" <[email protected]>
To   <[email protected]>
Subject   st: RE: -by- in ML
Date   Mon, 6 Jun 2005 14:58:25 -0700

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: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Monday, June 06, 2005 2:31 PM
To: [email protected]
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) *
	by us_id: gen double `last' = (_n==_N)
	mlsum `lnf' = `group_sum' if `last'

ml model d0 mylogit2 (y = x1 x2)
ml check
ml search
ml maximize

*   For searches and help try:

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