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, is already up and running.

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

st: RE: Plotting nonparametric reg. line alng with linear prediction line

From   Nick Cox <>
To   "''" <>
Subject   st: RE: Plotting nonparametric reg. line alng with linear prediction line
Date   Wed, 26 Oct 2011 13:45:02 +0100

Sounds like -lpoly-. 

As someone said, "The great thing about standards is that there are so many to choose from." I've met people who regard lowess, fractional polynomials and cubic splines as the standards. I suppose local linear regression looks standard from one mathematical-statistical viewpoint; it's just a pity that it often works rather poorly in practice. 


Ivica Rubil

Thanks Nick.
To be more specific, i just want the standard nonparametric stuff like
Nadaraya-Watson or local linear regression. How would either of these
fit in what you sent:
scatter y x || lfit y x || line ynpfitted x, sort

Nick Cox

-rcspline- from SSC is an example of a scatterplot smoother. (Deep
down, it is just another linear regression, but it is flexible in the
way that most nonparametric enthusiasts seek.) You could combine that
with a linear fit in this way.

. sysuse auto
(1978 Automobile Data)

. rcspline mpg weight, addplot(lfit mpg weight)

. rcspline mpg weight, lcolor(orange) addplot(lfit mpg weight,

The line colors are changed in the last example, because with default
defaults (-scheme s2color-) the lines come out as red and green, a
graphic combination better avoided because it is problematic for many
readers. (I use -set scheme s1color-, in my


On Wed, Oct 26, 2011 at 8:26 AM, Nick Cox <> wrote:
> As there are many nonparametric regression methods, you may need to be
> more specific, but
> scatter y x || lfit y x || line ynpfitted x, sort
> is a general recipe where -ynpfitted- is the prediction or smoothing
> from your nonparametric method.
> Nick
> On Wed, Oct 26, 2011 at 8:02 AM, Ivica Rubil <> wrote:
>> is there anybody who knows how to plot the scatter points, the linear
>> prediction line and a nonparametric regression line on together on
>> graph. I plotted scattered points and the linear proediction line,
but I
>> cannot add the nonparametric regression line. Any suggestions?

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index