I have fit a model in lmer that includes a three-way interaction term, where two of the variables are categorical and one is continuous. I am trying to recover the means parameterization for all slopes and intercepts rather than the effects parameterization which is the default in lmer, but am stuck on the proper coding. For example (without including the random effects), using the iris data set I made an extra categorical variable (Soil), and fit the model with species, sepal width and soil:
data(iris)
iris$Soil<-c(rep(c("Y","N"),75) #my made up second factor
summary(lm(Sepal.Length~Species*Soil*Sepal.Width-1-Species-Soil-Sepal.Width,data=iris))
gives the output of
Coefficients:
Estimate Std. Error t value Pr(>|t|)
Speciessetosa:SoilN 2.9752 0.7069 4.209 4.60e-05 ***
Speciesversicolor:SoilN 3.0580 0.8293 3.688 0.000324 ***
Speciesvirginica:SoilN 2.7583 0.7543 3.657 0.000362 ***
Speciessetosa:SoilY 1.9934 0.9520 2.094 0.038105 *
Speciesversicolor:SoilY 3.9449 0.7379 5.346 3.63e-07 ***
Speciesvirginica:SoilY 5.7967 0.9106 6.366 2.68e-09 ***
Speciessetosa:Sepal.Width 0.5962 0.2078 2.869 0.004765 **
Speciesversicolor:Sepal.Width 1.0210 0.2984 3.422 0.000819 ***
Speciesvirginica:Sepal.Width 1.2994 0.2488 5.223 6.33e-07 ***
SoilY:Sepal.Width 0.2747 0.3426 0.802 0.424163
Speciesversicolor:SoilY:Sepal.Width -0.5582 0.5255 -1.062 0.289953
Speciesvirginica:SoilY:Sepal.Width -1.3331 0.5240 -2.544 0.012061 *
The last three slope values (Soil = Y) are still in the effects parameterization, and I can't figure the proper coding to get the means. I assume this possible? Any suggestions would be greatly appreciated.
I'm not quite sure what you want, but I think this does it:
If you wanted to do it subtractively you could do it via
Do you want to center Sepal Width too (
scale(Sepal.Width,scale=FALSE))?You may find the
effectsandlsmeanspackages useful as well.