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   jpitblado@stata.com (Jeff Pitblado, StataCorp LP)
To   statalist@hsphsun2.harvard.edu
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 <mystata@hotmail.com> 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
jpitblado@stata.com
*
*   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