Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: RE: How to solve a problem with globals


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: Re: RE: How to solve a problem with globals
Date   Tue, 24 Feb 2009 22:58:55 +0100

<>

We can play all kinds of games with this thing, but really Tiago, have you been bitten by this or are you just trying things out?

HTH
Martin
_______________________
----- Original Message ----- From: "Kieran McCaul" <[email protected]>
To: <[email protected]>
Sent: Tuesday, February 24, 2009 10:51 PM
Subject: st: RE: How to solve a problem with globals


What if you define the -local- first, does that help?

. local i = 1

. global f_pA_`i' = 0.5

. dis $f_pA_1
.5



______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
The fact that no one understands you doesn't make you an artist.


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Tiago V.
Pereira
Sent: Wednesday, 25 February 2009 3:51 AM
To: [email protected]
Subject: st: How to solve a problem with globals

Dear statalisters,

Firstly, I would like to thank several statalisters for the splendid
help
in my previous questions.

Now, I am having the following problem:

. global f_pA_1 = 0.5

. local i = 1

. dis $f_pA_`i'
1

. dis $f_pA_1
.5

Is that normal?

All the best,

Tiago


I usually  need to compute a value X that satifies a specific condition.

A typical example is shown below. But this is only a single example, and
ordinarily I have similar, but more complex aims.

Hence, I would like to know your expert opinion on how one can make
codes
these kind of codes faster. Perhaps only Mata helps?



In this example, I want to compute the value of tau^2 that imposes the
lower limit of my confidence interval to be 0.

.
.
.
scalar lower_limit = 999999999
while lower_limit>0 {
local tau2 = `tau2'+0.0001
cap drop T_i V_i W_i WT
gene T_i= ln(_ES)
gene V_i = _selogES^2
gene W_i = 1/(V_i+`tau2')
gene WT = W_i*T_i
qui summ WT
scalar sum_WT = r(sum)
qui sum W_i
scalar sum_W_i = r(sum)
scalar summary_random = sum_WT/sum_W_i
scalar lower_limit = summary_random-(1.96/sqrt(sum_W_i))
}


Cheers!

Tiago







*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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