Dear Mike,

I believe that the following is the problem: For the regression of x on y, you have to move y to the left-hand-side of the equation to plot the line in {x, y}; so if the regression equation from the model x.y is x = a + b y, you need abline(-a/b, 1/b).

I hope that this helps,
 John

At 09:17 AM 2/20/2004 -0500, 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.


The data is read in grouped form( galton), and then ungrouped (galton2):

galton <- read.table("~/sasuser/data/galton.txt", header=TRUE)
# ungroup
galton2<-galton[rep(1:nrow(galton), galton$frequency), 1:2]

attach(galton)
sunflowerplot(child, parent, number=frequency, xlim=c(61,75), ylim=c(61,75),
   xlab="Child height", ylab="Mid Parent height")

# 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)

library(car)
data.ellipse(child, parent, plot.points=FALSE, levels=c(0.40, 0.68), lty=2)

The resulting figure may be seen at
http://euclid.psych.yorku.ca/SCS/Gallery/Private/galton.jpg

-Michael

--
Michael Friendly     Email: [EMAIL PROTECTED] Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: [EMAIL PROTECTED] phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to