Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: smooth quntile lines in graph


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <rasool.bux@aku.edu> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index