[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: local variables program
I want to run some regressions and have problems with the local and
global variables. I think Stata doesn't like the forval loop. How should
I refer to min and max? If you spot any other errors, it would be
appreciated.
local max=999999999999999999
sum avgunitprice if id==5, detail
global min=r(p5)
global max=r(p95)
forval i= min min+(max-min)/100 to max {
gen belowprice=avgunitprice*(avgunitprice<`i')
gen below=(avgunitprice<`i')
gen aboveprice=avgunitprice*(avgunitprice>=`i')
gen above=(avgunitprice>=`i')
qui reg lunit below belowprice above aboveprice if id==5, nocons
if e(rmse)<max {
local max=e(rmse)
reg lunit below belowprice above aboveprice
}
}
Dirk Nachbar
*
* 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/