plot output function
I guess you forgot that lines(x,y) , contrary to plot(x,y) needs *increasing* (or decreasing) `x' to make sense in your situation. Hence use something like plot(x,y) fit <- yourcoolfunction(x,y, ...) ix <- order(x) lines(x[ix], fit[ix], col = 2) HTH, Martin
"cp133" == cp133 <cp133 at york.ac.uk>
on Fri, 23 May 2003 17:03:35 +0100 writes:
cp133> no, I'm afraid abline does not help, it works only
cp133> for straight lines. The output of my function is a
cp133> vector of fitted values (called fit). I would like
cp133> to superimpose the fitted regression line to the
cp133> scatterplot of the data. Therefore, I use the
cp133> commands "plot(x,y)"to display the scatterplot; then
cp133> "lines(x,fit)" to add the estimated regression line.
cp133> The graph displays the scatterplot correctly but not
cp133> the fitted regression line. When I use the command
cp133> "plot(x,fit)" I get the correct regression line but
cp133> the plot is very rough, it looks like that, instead
cp133> of a single clear line, I get several thin lines.
cp133> Hope this is clearer.
cp133> Thank you,
cp133> Chiara
cp133> 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