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

Re: st: RE: RE: local macro in nlcom [nlcom bug?] Response to Nick


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: RE: RE: local macro in nlcom [nlcom bug?] Response to Nick
Date   Tue, 18 Nov 2003 11:49:59 -0600

Jun Xu <[email protected]> is having some trouble with local macro
expansions while using -nlcom-, pointing to out that the most likely source of
the problem is the following line in a program Jun wrote:

>         local ai = "1/exp(-_b[/lnalpha])"

The program later uses this macro in an expression for -nlcom-.

>         nlcom ///
> ((exp(lngamma(`i'+`ai'))/(exp(lnfact(`i'))*exp(lngamma(`ai'))))* ///
>                 ((`ai'/(`ai'+`expxb'))^`ai')* ///
>                 ((`expxb'/(`ai'+`expxb'))^`i'))

There problem is in the following piece of the above expression

>                 ((`ai'/(`ai'+`expxb'))^`ai')

In particular, when Stata expands the contents of local macro -ai-, it cannot
know that `ai' should probably be bound in parentheses; Stata expands macros
"as-is".  This is easily solved by explicit binding.

         local ai = "( 1/exp(-_b[/lnalpha]) )"

--Jeff
[email protected]
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index