Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Quai Maximum likelihood and multipul imputation

 From yoel ben or To statalist@hsphsun2.harvard.edu Subject Re: st: Quai Maximum likelihood and multipul imputation Date Tue, 22 Jan 2013 08:10:04 +0200

```Thank you very much Nick!
anyone for ny second question:

2. Because the data is imputed I tried to use the -mi estimate, cmdok: -,
but I keep getting an error.
If I put the -mi estimate, cmdok:-  before  -ml maximize-   I get the error:
"you must issue -ml model- first
an error occurred when mi estimate executed ml on m=2"
If I put  -mi estimate, cmdok:- before -ml model-  I get the error:
"macro e(cmd) is not set
matrix e(b) is not set
matrix e(V) is not set"
I will be more then grateful if you can explain to me what am I doing wrong?
Best,
Yoel Ben-Or
The Program:

> program yoel
>
> args lnf theta1 sigma
>
> tempvar g1 g2 g3
> local p1 \$ML_y1
> local p2 \$ML_y2
> local p3 \$ML_y3
> scalar  bb=ln(50000+(50000^2+1)^0.5)
> scalar  cc=ln(150000+(150000^2+1)^0.5)
> generate double `g1'=normal((bb-`theta1')/`sigma')-normal((0-`theta1')/`sigma')
> generate double `g2'=normal((cc-`theta1')/`sigma')-normal((bb-`theta1')/`sigma')
> generate double `g3'=1-normal((cc-`theta1')/`sigma')
> quietly replace `lnf'=`p1'*ln(`g1')+(1-`p1')*ln(1-`g1')+`p2'*ln(`g2')+(1-`p2')*ln(1-`g2')+`p3'*ln(`g3')+(1-`p3')*ln(1-`g3')
> end
>mi estimate, cmdok: ml model lf yoel (p1 p2 p3 = \$xlist)  /sigma
> ml search
> ml maximize

On Mon, Jan 21, 2013 at 8:42 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>
> I will peel off (1). Given a variable name and nothing else, -display-
> will always display the first value only. -display- is geared to
> producing single lines of output (there are exceptions to that not
> pertinent to your code), so it would typically only display an entire
> variable if called in a loop. But if you want to see more or even all
> of the values, use -list-.
>
> Nick
>
> On Mon, Jan 21, 2013 at 6:16 PM, yoel ben or <yoelbenor@gmail.com> wrote:
> > Dear Stata users,
> >
> > I use Stata 11. The Data which i am working on has multiple imputation
> > Data. I wrote a program using -Ml model-  which maximize a
> > quasi-maximum equation.
> >
> > I am having two problems:
> >
> > 1. I added a -display- option to see some of the calculations , and when
> > you run the program it seems like the program is using only the first
> > observation in the data while maximizing the equation.  when displaying the
> > calculation (p1, p2, p3) is always equal to (0, 0, 0) - the first
> > observation in the data.  you can see the program i wrote bellow.
> >
> > 2. Because the data is imputed I tried to use the -mi estimate, cmdok: -,
> > but I keep getting an error.
> >
> > If I put the -mi estimate, cmdok:-  before  -ml maximize-   I get the error:
> >
> > "you must issue -ml model- first
> >
> > an error occurred when mi estimate executed ml on m=2"
> >
> > If I put  -mi estimate, cmdok:- before -ml model-  I get the error:
> >
> > "macro e(cmd) is not set
> >
> > matrix e(b) is not set
> >
> > matrix e(V) is not set"
> >
> > I will be more then grateful if you can explain to me what am I doing wrong?
> > Best,
> > Yoel Ben-Or
> >
> > The Program:
> >
> > program yoel
> >
> > args lnf theta1 sigma
> >
> > tempvar g1 g2 g3
> >
> > local p1 \$ML_y1
> >
> > local p2 \$ML_y2
> >
> > local p3 \$ML_y3
> >
> > scalar  bb=ln(50000+(50000^2+1)^0.5)
> >
> > scalar  cc=ln(150000+(150000^2+1)^0.5)
> >
> > generate double `g1'=normal((bb-`theta1')/`sigma')-normal((0-`theta1')/`sigma')
> >
> > generate double `g2'=normal((cc-`theta1')/`sigma')-normal((bb-`theta1')/`sigma')
> >
> > generate double `g3'=1-normal((cc-`theta1')/`sigma')
> >
> > display as result `sigma',`theta1', "(",`g1', `g2' ,`g3',")",
> > "(",`p1',`p2', `p3',")"
> >
> > quietly replace
> > `lnf'=`p1'*ln(`g1')+(1-`p1')*ln(1-`g1')+`p2'*ln(`g2')+(1-`p2')*ln(1-`g2')+`p3'*ln(`g3')+(1-`p3')*ln(1-`g3')
> >
> > end
> >
> > ml model lf yoel (p1 p2 p3 = \$xlist)  /sigma
> >
> > ml search
> >
> > ml maximize
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```