problem with abline for x.y
On Friday 20 February 2004 08:17, Michael Friendly wrote:
I'm trying to do a sunflowerplot of Galton's data, with both regression
lines and data ellipses,
and I must be doing something wrong, because the lines do not intersect
at \bar{x}, \bar{y}.
The problem is likely in the line for x.y, but I don't know how to
specify that correctly.
[...]
# both attempts plot the same, wrong regression lines y.x <- lm(parent ~ child, weights=frequency) abline(y.x) x.y <- lm(child ~ parent, weights=frequency) abline(x.y, col="gray") attach(galton2) y.x <- lm(parent ~ child) abline(y.x, lwd=2) x.y <- lm(child ~ parent) abline(x.y, col="gray", lwd=2)
This looks like you are getting a line with equation of the form x = c0 + c1 y and then plotting the line y = c0 + c1 y You should probably do cx.y <- coef(x.y) cx.y <- c(-cx.y[1], 1) / cx.y[2] abline(cx.y) [Code untested, though] Deepayan