Hi, I read almost all I found in prior R-Help list about How to compare two regression line slopes.
So, I made a didactic example to illustrate a solution cited by Ben Bolker: =============================================== Subject: Re: [R] How to compare two regression line slopes From: Ben Bolker (bol...@ufl.edu) Date: Jan 27, 2009 1:52:20 pm List: org.r-project.r-help =============================================== I would like to know the opinion of other specialists. I'm needing do apply this solution in a real (and experimental) situation and the data are "like" iris data. # libraries library(ggplot2) # a example based in iris data (nonsense) qplot(Petal.Width, Sepal.Length, data=iris, facets= . ~ Species, geom=c('point', 'smooth'), se=F, method='lm', formula=y ~ x) # Function to test slope t.slope <- function(dF) { fit <- lm(y~x*f, data=dF) coef(summary(fit))["x:f2",] } # setosa vs. versicolor x <- subset(iris, Species != 'virginica', sel=Petal.Length)[,] y <- subset(iris, Species != 'virginica', sel=Petal.Width)[,] f <- factor(rep(1:2, each=50)) dF <- data.frame(x, y, f) t.slope(dF) # setosa vs. virginica x <- subset(iris, Species != 'versicolor', sel=Petal.Length)[,] y <- subset(iris, Species != 'versicolor', sel=Petal.Width)[,] f <- factor(rep(1:2, each=50)) dF <- data.frame(x, y, f) t.slope(dF) # versicolor vs. virginica x <- subset(iris, Species != 'setosa', sel=Petal.Length)[,] y <- subset(iris, Species != 'setosa', sel=Petal.Width)[,] f <- factor(rep(1:2, each=50)) dF <- data.frame(x, y, f) t.slope(dF) Thanks, -- ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria Estatistica - prof. Titular UESC/DCET/Brasil joseclaudio.fa...@gmail.com joseclaudio.fa...@terra.com.br ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ ______________________________________________ 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.