Statalist The Stata Listserver


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

st: RE: RE: RE: local variables program


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: local variables program
Date   Mon, 25 Jun 2007 14:10:46 +0100

I wouldn't expect this to work at all. 

What meets the eye is 

forval i = 1 2 100 { 

This isn't one of the legal forms of opening -forval- 
loops, as a careful look at the help will reveal. 

If you want to cycle over the integers 1...100
you can do it in various ways including 

forval i = 1 2 to 100 { 

forval i = 1(1)100 { 

forval i = 1/100 { 

I have not scrutinised the rest of the code carefully. 

Nick 
[email protected] 

Nachbar, Dirk
 
> Thanks Maarten
> 
> But that still doesn't work properly. I can't really figure 
> it out. See
> below for the amended program.
> 
> Dirk
> 
> 
> global maxRMSE=999999999999999999
> sum  avgunitprice if id==5, detail
> global min=r(p5)
> global max=r(p95)
> forval i= 1 2 100 {
> scalar j=$min+`i'*($max-$min)/100 
> gen belowprice=avgunitprice*(avgunitprice<`j') 
> gen below=(avgunitprice<`j')
> gen aboveprice=avgunitprice*(avgunitprice>=`j')
> gen above=(avgunitprice>=`j')
> qui reg lunit below belowprice above aboveprice if id==5, nocons
> if e(rmse)<$maxRMSE {
> local $maxRMSE=e(rmse)
> reg lunit below belowprice above aboveprice		
> }
> cap drop below belowprice aboveprice above j
> }

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