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

Re: st: Maximum-likelihood estimation

From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: Maximum-likelihood estimation
Date   Mon, 02 Feb 2004 23:49:39 -0600

David Greenberg <[email protected]> is having some trouble with the -ml- command:

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

I've run David's code verbatim on my home computer, and it worked fine.
I can only think of two things:

1. The definition for -mylogit- should have a version statement at the very

	program define mylogit
		version 8.2
		args lnf Xb
		replace `lnf' = -ln(1+exp(-`Xb')) if $ML_y1==1
		replace `lnf' = -`Xb' -ln(1+exp(-`Xb')) if $ML_y==0

2. David's Stata might not be up-to-date.  Look at the results of the
following command within Stata:

	. update query

[email protected]
*   For searches and help try:

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