Statalist The Stata Listserver


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

st: Re: RE: RE: RE: local variables program


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: RE: RE: RE: local variables program
Date   Mon, 25 Jun 2007 09:06:11 -0400

..
This won't work either. j is defined as a scalar, not a local macro, so `j' is blank. If you want j to be a scalar, then you just refer to it as if it were a variable - unless you have a variable named j, then refer to it as scalar(j). Also, why keep defining j inside the loop to the same value?

Michael Blasnik


----- Original Message ----- From: "Steichen, Thomas J." <[email protected]>
To: <[email protected]>
Sent: Monday, June 25, 2007 8:53 AM
Subject: st: RE: RE: RE: local variables program



How about this.... (edited lines commented out; some lines reordered)

global maxRMSE=999999999999999999
sum avgunitprice if id==5, detail
global min=r(p5)
global max=r(p95)
*forval i= 1 2 100 {
forval i = 1(2)100 {
scalar j = $min + `i' * ($max - $min) / 100
* gen belowprice=avgunitprice*(avgunitprice<`j')
gen below = avgunitprice < `j'
gen belowprice = avgunitprice * below
* gen aboveprice=avgunitprice*(avgunitprice>=`j')
gen above = avgunitprice >= `j'
gen aboveprice = avgunitprice * above
qui reg lunit below belowprice above aboveprice if id==5, nocons
if e(rmse) < $maxRMSE {
* local $maxRMSE=e(rmse)
global maxRMSE = e(rmse)
reg lunit below belowprice above aboveprice
}
* cap drop below belowprice aboveprice above j
cap drop below belowprice aboveprice above
}
di $maxRMSE


-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nachbar, Dirk
Sent: Monday, June 25, 2007 6:21 AM
To: [email protected]
Subject: st: RE: RE: local variables program

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