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

st: Re: MLE


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: MLE
Date   Tue, 07 Jun 2005 14:31:50 -0400

Stata hardly ever does things one observation at a time. You mylogit program will display the value of `a' for the first observation only each time it is called because when you say

di "a=" `a'

Stata sees that `a' is a variable name and displays `a'[1] because that is how it deals with -display var-, it displays the value of var[1]. If you wanted a full listing of `a' then you should tell stata to -list `a'-.

The reason you see a varying number of values output each time is that ml maximize needs to call your mylogit program multiple times in each iteration to figure out the next step in the maximization process (to calculate derivatives). You probably don't want to see a full listing of `a' for each of these calls.

Michael Blasnik
michael.blasnik@verizon.net


----- Original Message ----- From: <watt@fas.harvard.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, June 07, 2005 12:38 PM
Subject: st: MLE



Hi, everyone,

I'm wondering if anyone would be able to describe what the process is when Stata
runs the ml maximize command. I am running Stata 8.2

In particular, in my MLE model, I have included a command to display the
contents of a temporary variable.

If Stata loops through my program one datapoint at a time, I would expect to
seee the contents of this temporary variable for every datapoint in my sample.

However, Stata doesn't seem to do this. In the "zero" iteration, it displays my
variable 13 times. In the first iteration, it displays my variable 16 times. In
the second iteration, 9 times.

What is Stata doing to run this program? Thanks in advance.

Stanley

Here is my simple MLE program.

capture program drop mylogit3

program mylogit3
version 8.2
args todo b lnf
tempvar theta1 a c
mleval `theta1' = `b', eq(1)
quietly gen double `a' = exp(`theta1')/(1+exp(`theta1'))
quietly gen double `c' = 1/(1+exp(`theta1'))
di "a = " `a'
mlsum `lnf' = ln(`a'^($ML_y1) * `c'^(1-$ML_y1))
end

sort us_id
ml model d0 mylogit3 (indicator = w_rdsalperc)
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/



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