Statalist


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

Re: st: Lowess regression


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Lowess regression
Date   Sat, 1 Dec 2007 08:03:23 -0500

Honorati Masanja and Maarten:

It's usually better to work with integers and divide on the fly:

forval i=2/8 {
 lowess lnu5m year, bwidth(`=`i'/10') gen(alph`i')
}

or equivalently

forval i=2/8 {
 local j=`i'/10
 lowess lnu5m year, bwidth(`j') gen(alph`i')
}

though your example indicates you want 61 iterations, not 7, like so:

forval i=20/80 {
 lowess lnu5m year, bwidth(`=`i'/100') gen(alph`i')
}

I also recommend -lpoly- (for Stata 10, -findit locpoly- for older
Stata) over -lowess- for speed reasons, at least.  Try this:

forval i=1/18 {
 lpoly lnu5m year, bw(`=`i'/10') gen(alph`i') at(year) deg(1) nogr
}
sc lnu5m year || line alph1-alph18 year, sort

in Stata 10, or

forval i=1/18 {
 locpoly lnu5m year, w(`=`i'/10') gen(alph`i') at(year) deg(1) nogr
}
sc lnu5m year || line alph1-alph18 year, sort

in older Stata.

On Dec 1, 2007 6:09 AM, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
> --- Honorati Masanja <hmasanja@ihrdc.or.tz> wrote:
> > I'm running a lowess regress and have the follow code which I'll
> > appreciate your help
> >
> > forval i=0.2(0.1)0.8 {
> >   lowess lnu5m year, bwidth(`i') gen(alph`i')
> > }
> >
> > What I want is to have the variables alph as follows,
> >
> > if i=0.2   then  alph20
> > if i=0.21 then  alph21
>
> forval i=0.2(0.1)0.8 {
>     local j = `i' * 100
>     lowess lnu5m year, bwidth(`i') gen(alph`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–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index