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

From |
"Ashim Kapoor" <ashimkapoor@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: A query about min in stata |

Date |
Fri, 22 Aug 2008 21:27:58 +0530 |

Thank you, I really appreciate this tip. Ashim. On 8/22/08, Nick Cox <n.j.cox@durham.ac.uk> wrote: > Yes, the = sign has to be there. See help on -macro-. A generic example > is `= exp' where exp is an expression to be evaluated on the fly. > Without the = sign, Stata expects a local macro name. > > Consider > > `=`i'+9' > > The exp is `i' + 9. > > Consider now > > ``i'+9' > > Without the equals sign, Stata would see in this case 1+9, 2+9, etc. but > they are not macro names, so the thing would fail. > > Nick > n.j.cox@durham.ac.uk > > Martin Weiss > > Well, it calculates the endpoint of the rolling min calculation, > depending > on the index "i". To make Stata calculate, you put the equal sign in > front > of the mathematical expression. Not sure whether it has to be there, but > I > want to err on the safe side here... > > Ashim Kapoor > > What is that = doing in that statement starting with " qui " doing. It > works. But why ? > > On Fri, Aug 22, 2008 at 4:30 PM, Martin Weiss > > > If that is supposed to be some kind of "rolling" estimation, > > > > ************* > > sysuse auto , clear > > g rollingmin=. > > forv i =1/65{ > > qui su mpg in `i'/`=`i'+9' > > di in red "min in `i' to `=`i'+9': " r(min) _n > > qui replace rollingmin = r(min) in `i' > > } > > > > l rollingmin > > ************* > > Ashim Kapoor > > > I am trying to do the following : - > > > > I have a variable r. I want to create a variable m=min( r, r[_n-1], > > ... ,r[_n-9]) > > > > I guess I can use a while loop to do this but that is quite slow. An > > alternative would be to define r0=r,r1=r[_n-1],..,r9=r[_n-9] > > and then say m=rmin ( r0 r1 ... r9). > > > > My question is that is there a built in way in stata to do this ? like > > say by using egen ? > > * > * 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/

**References**:**st: A query about min in stata***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**Re: st: RE: A query about min in stata***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**RE: st: RE: A query about min in stata***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: A query about min in stata** - Next by Date:
**Re: st: error message when constructing histograms** - Previous by thread:
**RE: st: RE: A query about min in stata** - Next by thread:
**st: Pooled Data tests and Quantile Regressions** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |