e-letter wrote:
On 14/09/2009, Steve Lianoglou <mailinglist.honey...@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:
Hope this example is not in Crawley's book as you cite it, because you
need to make the plot large enough to include the value (40,4) already
when you create the plot, e.g., by specifying xlim and ylim.
Anyway, I'd rather explude the value from a data.frame as fol#ows:
# whole data:
dat <- data.frame(x = c(0,10,20,30,40), y = c(5,9,12,19,4))
dat
plot(y~x, data=dat)
# fit the regression without the 5th observation:
fit <- lm(y ~ x, data=dat[-5,])
abline(fit)
Uwe Ligges
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.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.