Celine--
You can also use -lpoly-, with the -deg(1)- option for local linear
regression, with a very easy syntax:
webuse nhanes2
lpoly wei hei [aw=final]
lpoly wei hei [aw=final], deg(1)
and work only at some values of X to speed up the process:
gen x=_n+134 in 1/66
lpoly wei hei [aw=final], deg(1) gen(def) at(x)
and quietly save the results if you want to compare different smoothnesses:
lpoly wei hei [aw=final], deg(1) bw(.5) gen(wh) at(x) nogr
lpoly wei hei [aw=final], deg(1) bw(1) gen(w1) at(x) nogr
lpoly wei hei [aw=final], deg(1) bw(4) gen(w4) at(x) nogr
line wh w1 w4 x
Note that [aweight]s are more appropriate for your data than the above
NHANES data (which should really use [pweights], so the weight option
above is not useful for SEs or CIs in the example, but should work
nicely for you).
On Dec 14, 2007 8:19 AM, Celine Carrere <[email protected]> wrote:
> I work on Stata 10 so I will try the restricted cubic splines...
> Thanks!!
> C�line
>
>
> Nick Cox a �crit :
>
> > This is difficult. -lowess- doesn't accept weights. The most
> > obvious reason is that it uses weights internally as a key part
> > of the lowess algorithm.
> >
> > In principle, you could -expand- the data first to replicate the
> > effect of frequency weights, but that might leave you with a dataset
> > of millions, and very slow -lowess-. On the other hand, something like
> > this
> >
> > gen popwt = round(pop/1000)
> > expand popwt
> > lowess ...
> >
> > would be in practice surely precise enough, and faster.
> >
> > However, an alternative is to use restricted cubic splines,
> > for which weights are allowed.
> > -rcspline- from SSC would automate that you (and be _much_
> > faster). Stata 10 is needed.
> >
> > Celine Carrere
> >
> >
> > I use the command "Lowess" to obtain the locally weighted regression of
> > the "wage growth" (yvar) on a "geographical variable" (xvar). My
> > individuals are cities and I would like to (also) weight the regression
> > of yvar on xvar by the number of inhabitants in the city. How can I do?
*
* 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/