Hello, We've got a dataset with several variables, one of which we're using to split the data into 3 smaller subsets. (as the variable takes 1 of 3 possible values). There are several more variables too, many of which we're using to fit regression models using lm. So I have 3 models fitted (one for each subset of course), each having slope estimates for the predictor variables. What we want to find out, though, is whether or not the overall slopes for the 3 regression lines are significantly different from each other. Is there a way, in R, to calculate the overall slope of each line, and test whether there's homogeneity of regression slopes? (Am I using that phrase in the right context -- comparing the slopes of more than one regression line rather than the slopes of the predictors within the same fit.) I hope that makes sense. We really wanted to see if the predicted values at the ends of the 3 regression lines are significantly different... But I'm not sure how to do the Johnson-Neyman procedure in R, so I think testing for slope differences will suffice! Thanks to any who may be able to help! Doug Adams
Hello Doug, Perhaps it would just be easier to keep your data together and have a single regression with a term for the grouping variable (a factor with 3 levels). If the groups give identical results the coefficients for the two non-reference grouping variable levels will include 0 in their confidence interval. Michael On 14 September 2010 06:52, Doug Adams <fog0 at gmx.com> wrote:> Hello, > > We've got a dataset with several variables, one of which we're using > to split the data into 3 smaller subsets. ?(as the variable takes 1 of > 3 possible values). > > There are several more variables too, many of which we're using to fit > regression models using lm. ?So I have 3 models fitted (one for each > subset of course), each having slope estimates for the predictor > variables. > > What we want to find out, though, is whether or not the overall slopes > for the 3 regression lines are significantly different from each > other. ?Is there a way, in R, to calculate the overall slope of each > line, and test whether there's homogeneity of regression slopes? ?(Am > I using that phrase in the right context -- comparing the slopes of > more than one regression line rather than the slopes of the predictors > within the same fit.) > > I hope that makes sense. ?We really wanted to see if the predicted > values at the ends of the 3 regression lines are significantly > different... But I'm not sure how to do the Johnson-Neyman procedure > in R, so I think testing for slope differences will suffice! > > Thanks to any who may be able to help! > > Doug Adams > > ______________________________________________ > R-help at 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. >
Allow me to add to Michael's and Clifford's responses. If you fit the same regression model for each group, then you are also fitting a standard deviation parameter for each model. The solution proposed by Michael and Clifford is a good one, but the solution assumes that the standard deviation parameter is the same for all three models. You may want to consider the degree by which the standard deviation estimates differ for the three separate models. If they differ wildly, the method described by Michael and Clifford may not be the best. Rather, you may want to consider gls() in the nlme package to explicitly allow the variance parameters to vary. -tgs On Mon, Sep 13, 2010 at 4:52 PM, Doug Adams <fog0@gmx.com> wrote:> Hello, > > We've got a dataset with several variables, one of which we're using > to split the data into 3 smaller subsets. (as the variable takes 1 of > 3 possible values). > > There are several more variables too, many of which we're using to fit > regression models using lm. So I have 3 models fitted (one for each > subset of course), each having slope estimates for the predictor > variables. > > What we want to find out, though, is whether or not the overall slopes > for the 3 regression lines are significantly different from each > other. Is there a way, in R, to calculate the overall slope of each > line, and test whether there's homogeneity of regression slopes? (Am > I using that phrase in the right context -- comparing the slopes of > more than one regression line rather than the slopes of the predictors > within the same fit.) > > I hope that makes sense. We really wanted to see if the predicted > values at the ends of the 3 regression lines are significantly > different... But I'm not sure how to do the Johnson-Neyman procedure > in R, so I think testing for slope differences will suffice! > > Thanks to any who may be able to help! > > Doug Adams > > ______________________________________________ > 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. >[[alternative HTML version deleted]]