Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: programming maximum likelihood estimation for specific logistic function

 From Miriam Dietrich To statalist@hsphsun2.harvard.edu Subject Re: st: programming maximum likelihood estimation for specific logistic function Date Thu, 9 Aug 2012 21:12:48 +0100

```Hi Matt,

Best wishes,
Miriam

2012/8/9 Matthew Baker <matthew.baker@hunter.cuny.edu>:
> Miriam --
>
> It looks to me like you just need to specify a second variable in the
> "model" statement. That is:
>
> ml model lf mylogit ( bserved= titfortat) ()
>
>
> ml model lf mylogit ( bserved= titfortat)
>
> Best,
>
> Matt Baker
>
> On Wed, Aug 8, 2012 at 3:24 PM, Miriam Dietrich <miri.dietrich@gmail.com> wrote:
>> Hello,
>>
>> I want to run a maximum likelihood estimation of the following
>> logistic function:
>>
>> L=ππ(1/(1+e^(-x/variance) ))^y (1/(1+e^(x/variance) ))^(1-y)
>>
>> And this is what I wrote in Stata:
>>
>> program define mylogit
>> 1.
>> . args lnf mu sigma
>> 2.
>> . quietly replace `lnf' = -ln(1+exp(-`mu'/`sigma')) if \$ML_y1==1
>> 3.
>> . quietly replace `lnf' =-ln(1+exp(`mu'/`sigma')) if \$ML_y1==0
>> 4.
>> . end
>> . ml model lf mylogit ( bserved= titfortat)
>> . ml maximize
>>
>> The problem is that Stata gives me an error message saying invalid name.
>>
>> I have also tried a couple of variations to understand what the
>> problem might be. It works if I use:
>> quietly replace `lnf' = -ln(1+exp(-`Xb')) if \$ML_y1==1
>> but if i use quietly replace `lnf' = -ln(1+exp(-`Xb'/`sigma')) if
>> \$ML_y1==1 it says unknown function.
>>
>> Does anyone has any ideas?
>>
>>
>> Miriam
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>
>
>
> --
> Dr. Matthew J. Baker
> Department of Economics
> Hunter College and the Graduate Center, CUNY
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```