I would like to test the difference in response of two variables to one predictor. Here is a minimal reproducible example.
library(nlme)
## gls is used in the application; lm would suffice for this example
m.set <- gls(Sepal.Length ~ Petal.Width, data = iris,
subset = Species == "setosa")
m.vir <- gls(Sepal.Length ~ Petal.Width, data = iris,
subset = Species == "virginica")
m.ver <- gls(Sepal.Length ~ Petal.Width, data = iris,
subset = Species == "versicolor")
I can see that the slope coefficients are different:
m.set$coefficients
(Intercept) Petal.Width
4.7771775 0.9301727
m.vir$coefficients
(Intercept) Petal.Width
5.2694172 0.6508306
m.ver$coefficients
(Intercept) Petal.Width
4.044640 1.426365
I have three questions:
- How can I test the difference between slopes?
- How can I test the difference between residual variances?
- What is a simple, effective way to present these comparisons?
A related question, Method to compare variable coefficient in two regression models, suggests re-running the model with a dummy variable to differentiate the slopes, are there options that would allow the use of independent data sets?