--- Edit ---
Let's take a very simple model, with Y and X numerical variables and Fact a categorical variable.
mod = lm(Y~X*Fact)
I want to:
- Check whether there are differences of Y between the Fact categories; i.e. to make pairwise comparisons of means of Y for Fact categories :
This can be easily done with the glht package :
summary(glht(mod, mcp(Fact ="Tukey")))
- And whether the slopes of y=f(x) are different for each value of Fact; again with pairwise comparisons. This is what I cannot find.
I found many discussions about glht or lsmeans here and elsewhere (1)(2)(3)(4) but they are all about interactions between two factors, not numerical variable*factor, so I wonder if I might have missed something obvious there?
X
. I thinkglht
uses the mean ofX
but am not sure. At any rate, it is extremely important to state whichX
is being used; otherwise, we're not giving the complete story. The code in my answer shows how to do this for 3 differentX
values. $\endgroup$