Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: ml graph returns error


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: ml graph returns error
Date   Tue, 22 Mar 2011 08:31:10 +0000 (GMT)

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


--- On Mon, 21/3/11, B Villena wrote:
> My model looks like this
>
> program mymod
> args lnf xv xi phi z
> tempvar xb
> qui gen double `xb' = (`xv'-$xm)*(`phi'*(`xi'-$xm)+$xm-`z')
> qui replace `lnf' =ln(normal(`xb' )) if $ML_y1==1
> qui replace `lnf' =ln(1-normal(`xb' )) if $ML_y1==0
> end
>
> where $xm is just a given constant. I checked that this model is 
> identified, in the sense that all first-order conditions are linearly
> independent.
>
> Then I run my model by using ml
>
> ml model lf voter_lf (Xv: q = A_*, nocons) (Xi: B_*, nocons) (phi:) 
> (lambda: zs, nocons)
>
> where A_* is a set of saturated dummy variables, i.e. sum of all A_ add 
> up to 1; and B_* is another set of saturated dummies. Of course, A and B 
> variable sets are linearly independent, i.e.
> if for all observations with A_j==1 there are some of them for which 
> B_k==0 and B_k==1 for all k=1,2,3,....K, and j=1,2,3,...J
>
> Here is the problem. If I run
> ml model lf mymod (Xv: q = A_*, nocons) (Xi: B_*, nocons) (phi:) 
> (lambda: zs, nocons)
> ml search
> ml check
> ml maximize
> ml graph
>
> everything looks just fine. The model passes all 10 checks and the model 
> is estimated with sensible parameters.
> The first problem occurs at this stage. I'm running this model many 
> times for different samples. Although I obtain the ml estimates, ml 
> graph returns an error message
>
> Mopt_graph_gen(): 3301 subscript invalid
> : - function returned error
> r(3301);
> r(3301);
>
>
> The second problem arises when I put ml check after ml search. 
> Specifically, I run
>
> ml model lf mymod (Xv: q = A_*, nocons) (Xi: B_*, nocons) (phi:) 
> (lambda: zs, nocons)
> ml check
> ml search
> ml maximize
> ml graph
>
> I get the following error
>
> Test 1: Calling voter_lf to check if it computes log likelihood and
> does not alter coefficient vector...
> opt__eval_cycle(): 3301 subscript invalid
> opt__eval(): - function returned error
> _optimize_evaluate(): - function returned error
> _mopt__evaluate(): - function returned error
> mopt__check_test1(): - function returned error
> _moptimize_check(): - function returned error
> Mopt_check(): - function returned error
> : - function returned error
> r(3301);
> r(3301); 

I can see two problems:

The paremeter of phi and the parameters of `xi' are
very weakly identified, in that identification only 
seems to come from that external constant $xm. If we
excluded that and we found some estimates for these 
parameters, and than multiplied phi by 2 and divided 
all parameters of `xi' by 2, than the likelihood 
would not change, same if we divided and multiplied 
by 2, e, 3, pi, etc. That is, in that case the model
would not be identified. It is just that $xm is fixed
and thus cannot be multiplied or divided that 
identification happens, but it seems to me rather 
weak and I am not surprised that computers have a 
hard time with this likelihood function.


Second, I would replace:
qui replace `lnf' =ln(1-normal(`xb' )) if $ML_y1==0

with:
qui replace `lnf' =ln(normal(-`xb')) if $ML_y1==0

Mathematically the two statements are equivalent, 
but the latter is much easier for computers. Since 
this is already a hard problem, you need to use 
whatever trick available to make it easier for the 
computer.

Hope this helps,
Maarten


      

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index