Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: problem with scalar in ml program


From   "Robert Duval" <rduval@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: problem with scalar in ml program
Date   Fri, 9 Feb 2007 17:25:36 -0500

Dear all,

I have a ml program that fails to pass the ml check. Aparently the
problem occurs when ml fails to recognize one of the args (athrho)
passed to the ln function. However, I have another almost identical
program that runs perfectly!?!

I've been through the my code several times and I cannot see why ml
check finds a mistake in one of my programs and not in the other.

***Here is the program that runs just fine:

program define mybiprob_lf
version 8.2
args lnf xb1 xb2 athrho
quietly {
	tempname rho
	scalar `rho'=(exp(2*`athrho')-1)/(exp(2*`athrho')+1)
	replace `lnf' = ln(binormal(`xb1',`xb2',`rho'))      if $ML_y1 == 1
	replace `lnf' = ln(binormal(-`xb1',`xb2',-`rho') +
binormal(`xb1',-`xb2',-`rho') + binormal(-`xb1',-`xb2',`rho'))    if
$ML_y1 == 0
}
end


***Here is the one that fails to work:

program define mybiprob_het
version 8.2
args lnf axb1 axb2 ux1 ux2 athrho
quietly {
	tempvar sig1 sig2 xb1 xb2
	tempname rho
	scalar `rho'=(exp(2*`athrho')-1)/(exp(2*`athrho')+1)

	gen double `sig1' = exp(`ux1')
	gen double `sig2' = exp(`ux2')
	gen double `xb1'  = `axb1'/`sig1'
	gen double `xb2'  = `axb2'/`sig2'

	replace `lnf' = ln(binormal(`xb1',`xb2',`rho'))      if $ML_y1 == 1
	replace `lnf' = ln(binormal(-`xb1',`xb2',-`rho') +
binormal(`xb1',-`xb2',-`rho') + binormal(-`xb1',-`xb2',`rho'))    if
$ML_y1 == 0
}
end


****and here is the trace of my ml execution

. ml model lf mybiprob_het (Worker: f_w = $Z1) (Employer: $X) /athrho,
svy subpop(filt2)

.
end of do-file

. ml check

Test 1:  Calling mybiprob_het to check if it computes log pseudolikelihood and
        does not alter coefficient vector...
        FAILED; mybiprob_het returned error 198.

Here is a trace of its execution:
------------------------------------------------------------------------------
-> mybiprob_het __00000A __000007 __000008 __000009
           - `begin'
           = capture noisily version 9.2: mybiprob_het __00000A
__000007 __000008 __000009
             -------------------------------------------------------------------------------
begin mybiprob_het ---
             - version 8.2
             - args lnf axb1 axb2 ux1 ux2 athrho
             - quietly {
             - tempvar sig1 sig2 xb1 xb2
             - tempname rho
             - scalar `rho'=(exp(2*`athrho')-1)/(exp(2*`athrho')+1)
             = scalar __00000F=(exp(2*)-1)/(exp(2*)+1)
2* invalid name
               gen double `sig1' = exp(`ux1')
               gen double `sig2' = exp(`ux2')
               gen double `xb1' = `axb1'/`sig1'
               gen double `xb2' = `axb2'/`sig2'
               replace `lnf' = ln(binormal(`xb1',`xb2',`rho')) if $ML_y1 == 1
               replace `lnf' = ln(binormal(-`xb1',`xb2',-`rho') +
binormal(`xb1',-`xb2',-`rho') + binormal(-`xb1',-
`xb2',`rho')) if $ML_y1 == 0
               }
             ---------------------------------------------------------------------------------
end mybiprob_het ---
           - `end'
           = set trace off
------------------------------------------------------------------------------
Fix mybiprob_het.
r(198);



The problem hence lies when it reads

             - scalar `rho'=(exp(2*`athrho')-1)/(exp(2*`athrho')+1)
             = scalar __00000F=(exp(2*)-1)/(exp(2*)+1)
2* invalid name

and it fails to generate a temporary variable storing `athrho'... any
clues as to why this is happening?

Furthermore why does it happens in one program and not in the other?

any help would be greatly appreciated.
thx.
robert
*
*   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