[R] linear regression, exclude a datum
e-letter
inpost at gmail.com
Tue Sep 15 08:43:26 CEST 2009
On 14/09/2009, Steve Lianoglou <mailinglist.honeypot at gmail.com> wrote:
> Hi,
>
> On Sep 14, 2009, at 9:47 AM, e-letter wrote:
>
>> Readers,
>>
>> I have been reading the r book (Crawley) and tried to use the
>> influence measures function for linear regression, as described. I
>> have one datum that I wish to show in the graph but exclude from the
>> regression and ab line.
>>
>> x y
>> 0 5
>> 10 9
>> 20 10
>> 30 19
>> 40 4
>>
>> With the influence measures function I plot the graph but linear
>> regression includes the datum (40,4), which I want to show on the
>> graph but exclude from the linear regression ab line.
>>
>> Is there an alternative package to perform this task please?
>
> Please post the code you're using to try and do the regression.
>
> I think you simply want to remove the data point when you build the
> regression model, then plot it later after you plot the regression.
>
Correct; below are my commands:
x<-c(0,10,20,30)
y<-c(5,9,12,19)
fit<-lm(y~x)
plot(y~x)
abline(fit)
I try these commands as explained in section 12 (graphics) of the
introduction manual:
points(40,4)
plot(40,4,add=TRUE)
Warning messages:
1: "add" is not a graphical parameter in: plot.window(xlim, ylim, log,
asp, ...)
2: "add" is not a graphical parameter in: plot.xy(xy, type, pch, lty,
col, bg, cex, lwd, ...)
3: "add" is not a graphical parameter in: axis(side, at,
as.graphicsAnnot(labels), tick, line, pos, outer,
4: "add" is not a graphical parameter in: axis(side, at,
as.graphicsAnnot(labels), tick, line, pos, outer,
5: "add" is not a graphical parameter in: box(which = which, lty = lty, ...)
6: "add" is not a graphical parameter in: title(main, sub, xlab, ylab,
line, outer, ...)
The datum is not added to the original graph.
More information about the R-help
mailing list