Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: smooth quntile lines in graph


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: smooth quntile lines in graph
Date   Fri, 30 Nov 2012 09:13:40 +0000

You asked -bsqreg- for linear regressions on weight, so that it is
what it gave you. Adding a -lowess- plot just adds a lowess plot, and
does not modify the previous results from -*qreg-.

I doubt that -lowess- and quantiles mix easily (why should they), but
you could use quantile regression in conjunction with fractional
polynomials or cubic splines. You should explore the options of
-fpoly- and -mkspline, cubic-.

sysuse auto, clear
fracpoly qreg mpg weight, q(5)
predict f5
fracpoly qreg mpg weight, q(95)
predict f95
mkspline sweight=weight, cubic nknots(3)
qreg mpg sweight*, q(5)
predict s5
qreg mpg sweight*, q(95)
predict s95
line f95 s95 f5 s5 weight, sort ///
lp(solid dash solid dash) lcolor(blue red blue red) ///
legend(order(1 "fpoly 95%" 2 "spline 95%" 3 "fpoly 5%" 4 "spline 5%")
col(1) ring(0) pos(2)) ///
|| scatter mpg weight, mcolor(green) ms(oh) ytitle(`: var label mpg')


On Fri, Nov 30, 2012 at 5:52 AM, rasool.bux <[email protected]> wrote:

> I am trying to make a lowess graph with quitiles (5, 95). But the quantile lines are just straight lines. I want them to be smooth like lowess line. Is there any option to do that in STATA?
>
> ***********
> sysuse auto,clear
> bsqreg mpg weight, quantile(5)
> predict p5
> bsqreg mpg weight, quantile(95)
> predict p95
> twoway (scatter mpg weight) (lowess mpg weight) (line p5 weight) (line p95 weight)
> ****************
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index