Statalist The Stata Listserver


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

Re: st: Loess confidence bands


From   "Stas Kolenikov" <[email protected]>
To   [email protected]
Subject   Re: st: Loess confidence bands
Date   Wed, 7 Mar 2007 23:28:46 -0600

If you are not terribly committed to -lowess- per se, but want to get
a non-parametric smooth curve with nice confidence bands, you could
look into spline regression. The idea is that you create splines that
look like local bumps, pretty much like a kernel, and you run a
-regress-ion on those bumps. As is always the case with -regress-, you
can then -predict- the point esimates and standard errors, and plot
them however you like.

This is quick and dirty, and it uses my version of B-splines routine
-- there is a more official one by Roger Newson; mine is available off
my webpage.

sysuse auto
bspl weight, knots(7) out prefix(_B)
regress price weight _B*
predict yfit , xb
predict sefit, stdp
gen y_hi = yfit + 1.96*sefit
gen y_lo = yfit - 1.96*sefit
twoway rarea y_lo y_hi weight, sort || line yfit weight, sort ||
scatter price weight

No need to bootstap, fast and handy :)). You can improve the look
somewhat by taking a grid of points rather than available points.

On 3/7/07, Paswel Phiri Marenya <[email protected]> wrote:
Dear all:
How do I get confidence bands around my loess graphs? i.e

loess y x (what else do I need to do to show confidence band on the plot?)

Thanks
Paswel

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


--
Stas Kolenikov
http://stas.kolenikov.name
*
*   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