[R] plot output function
Roger Bivand
Roger.Bivand at nhh.no
Fri May 23 18:32:46 CEST 2003
On Fri, 23 May 2003, cp133 wrote:
> no, I'm afraid abline does not help, it works only for straight lines.
>
> The output of my function is a vector of fitted values (called fit).
> I would like to superimpose the fitted regression line to the
> scatterplot of the data.
> Therefore, I use the commands "plot(x,y)"to display the scatterplot;
> then
> "lines(x,fit)" to add the estimated regression line.
> The graph displays the scatterplot correctly but not the fitted
> regression line.
> When I use the command "plot(x,fit)" I get the correct regression line
> but the plot is very rough, it looks like that, instead of a single
> clear line, I get several thin lines.
>
Please make sure the x are in increasing order, and the fit vector
re-ordered to match, something like:
o <- order(x)
lines(x[o], fit[o])
I think the line is zigzagging backwards and forwards along the x vector.
> Hope this is clearer.
>
> Thank you,
>
> Chiara
>
> Uwe Ligges wrote:
> >
> > cp133 wrote:
> > > Hi,
> > >
> > > I have written my own function to estimate a local linear regression.
> > > When I plot the output vector on the scatterplot of the data, the
> > > function lines does not work and I get a rescaled regression line.
> > > When I plot the output vector alone, the graph looks right, but choosing
> > > the type "line" instead of the default does not deliver a clear single
> > > line.
> > >
> > > Does somebody know why this is happening.
> > >
> >
> > Does abline() help?
> >
> > If not, please be more specific in your question and tell us what you
> > are exactly going to do.
> >
> > Uwe Ligges
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list