Statalist


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

st: Quotes around r() macros


From   Alek <[email protected]>
To   [email protected]
Subject   st: Quotes around r() macros
Date   16 May 2008 17:31:01 +0200

Why the following two formulas - with and without quotes around r() macros (see below) - produce very different results if the value stored in the r() macro is negative? I attach a part of a Stata output (Stata10SE, WindowsXP). Should not all macros, including the r() macros, be quoted?

Aleksander Rutkowski

corr empl0 empl1
local t = r(rho) * sqrt((r(N)-2)/(1-r(rho)^2))
local t2 = `r(rho)' * sqrt((`r(N)'-2)/(1-`r(rho)'^2))
local p = 2*ttail(r(N)-2,abs(`t'))
local p2 = 2*ttail(`r(N)'-2,abs(`t2'))
di "r(rho): " r(rho) "   r(rho)': " `r(rho)'
di "r(N): " r(N) "   r(N)': " `r(N)'
di "t: " `t' "   t2: " `t2' "   p: " `p' "   p2: " `p2'
di

Example of Stata output:

r(rho): -.58133648   r(rho)': -.58133648
r(N): 10   r(N)': 10
t: -2.0208211   t2: -1.4215178   p: .07795928   p2: .19295556

r(rho): .85050034   r(rho)': .85050034
r(N): 10   r(N)': 10
t: 4.5735645   t2: 4.5735645   p: .00181727   p2: .00181727

r(rho): .00749718   r(rho)': .00749718
r(N): 10   r(N)': 10
t: .02120583   t2: .02120583   p: .98360083   p2: .98360083

r(rho): -.7597187   r(rho)': -.7597187
r(N): 10   r(N)': 10
t: -3.3045795   t2: -1.7110323   p: .01078497   p2: .12543946

r(rho): .18673805   r(rho)': .18673805
r(N): 10   r(N)': 10
t: .53763206   t2: .53763206   p: .60545943   p2: .60545943

r(rho): .64313145   r(rho)': .64313145
r(N): 10   r(N)': 10
t: 2.3754968   t2: 2.3754968   p: .04485987   p2: .04485987

r(rho): .74453652   r(rho)': .74453652
r(N): 10   r(N)': 10
t: 3.1544711   t2: 3.1544711   p: .01350709   p2: .01350709

r(rho): .88701037   r(rho)': .88701037
r(N): 10   r(N)': 10
t: 5.4333446   t2: 5.4333446   p: .00062087   p2: .00062087

r(rho): -.2475888   r(rho)': -.2475888
r(N): 10   r(N)': 10
t: -.72279083   t2: -.67976198   p: .49039643   p2: .51583887


----------------------------------------------------------------------
Moj dom. Moje szczescie. Poczuj jak to jest.
Prowizja 0% i niska rata w kredycie hipotecznym Banku Millennium.
Sprawdz: http://link.interia.pl/f1dec


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