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

From |
"Jitian Sheu" <jtsheu@bu.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Inconsistent Result of generating variables |

Date |
Fri, 9 Apr 2004 22:12:02 -0400 |

Hello, What I meant is that this time, the result is "correct". Both formula produce the same results. Thanks. Jitian ----- Original Message ----- From: "Richard Williams" <Richard.A.Williams.5@nd.edu> To: <statalist@hsphsun2.harvard.edu> Sent: Friday, April 09, 2004 10:08 PM Subject: Re: st: Inconsistent Result of generating variables > At 09:22 PM 4/9/2004 -0400, Jitian Sheu wrote: > >Hello, Thank you very much. > >Based on your explaination, I try to use: (`b21')^2 instead of using > >`b21'^2. > >Stata creates the same results. > > I hope you mean you got the same results as I did, not the same incorrect > results you got earlier! Anyway, here is the Stata FAQ I was thinking of - > "I coded 'a'2 and got the wrong sign. Why?" See > > http://www.stata.com/support/faqs/lang/macpow.html > > The trick is that when you say, > > local b21=-0.25 > > You naturally assume that Stata will think `b21' means "negative > .25". But, Stata actually interprets it as "minus .25". Hence, with > `b21'^2, exponentiation gets done first and then subtraction, leaving you > with -.0625 rather than +.0625. > > The FAQ suggests two workarounds: > > * Use scalars instead of local macros, e.g. > > scalar b21 = -.25 > > * Or, bind the macro in parentheses when taking powers, e.g > > (`b21')^2 > > * > * 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/ > * * 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/

**References**:**Re: st: RE: tabodds.ado***From:*khigbee@stata.com

**Re: st: Inconsistent Result of generating variables***From:*Richard Williams <Richard.A.Williams.5@nd.edu>

**Re: st: Inconsistent Result of generating variables***From:*Richard Williams <Richard.A.Williams.5@nd.edu>

- Prev by Date:
**Re: st: Inconsistent Result of generating variables** - Next by Date:
**Re: st: Inconsistent Result of generating variables** - Previous by thread:
**Re: st: Inconsistent Result of generating variables** - Next by thread:
**Re: st: Inconsistent Result of generating variables** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |