Compare slops of two linear regression
uestcwangxiao opened this issue · comments
Is there any way to perform a statistical test to see whether the slopes of the two linear regression are significantly different from each other. Thank you.
Yes, see the first answer in this stack overflow thread: https://stats.stackexchange.com/questions/33013/what-test-can-i-use-to-compare-slopes-from-two-or-more-regression-models
Under "1. How can I test the difference between slopes?"
Thank you for your reply. But it looks like it is paired data in the link. How about the unpaired data? let's say we have two groups of data, Y1 = a1X1 +b1, Y2 = a2X2 +b2, how to test a1 = b1? Sorry I'm really new to R and also statistics.
I haven't directly compared two slopes and find P value, so I am actually not sure. But I do know is you can find the 95% confidence intervals of the slopes and see if they overlap. Try this example:
head(iris)
m1 <- lm(Sepal.Length ~ Sepal.Width, data = iris)
head(CO2)
m2 <- lm(conc ~ uptake, data = CO2)
summary(m1)
summary(m2)
confint(m1, 'Sepal.Width', level=0.95)
confint(m2, 'uptake', level=0.95)