I am trying to get estimates of Linear mixed model using lmer from lme4 R package for explanatory variables. My code looks like:
lmm31<-lmer(logvalue~concentration+variable+species+species:concentration+(1|idsp), data=prirstart2)
lsmeans(lmm31, prirstart2$species)
I get an error:
Error in ref.grid(object = <S4 object of class "ref.grid">) :
Can't handle an object of class “ref.grid”
Use help("models", package = "lsmeans") for information on supported models.
Each explanatory variable is coded as factor. When I look on the class of the object returned by lmer function
class(lmm31)
I get
[1] "lmerMod"
attr(,"package")
[1] "lme4"
ref.grid returns
ref.grid(lmm31)
'ref.grid' object with variables:
concentration = con0, con100, con5, con50
variable = p1, p2, p3
species = arenosa, columbiana, halleri, ratkovo
If I try pairwise comparison using multicomp package, it works fine
summary(glht(lmm31, linfct=mcp(species="Tukey")))
Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: Tukey Contrasts
Fit: lmer(formula = logvalue ~ concentration + variable + species + species:concentration + (1 | idsp), data = prirstart2)
Linear Hypotheses:
Estimate Std. Error z value Pr(>|z|)
columbiana - arenosa == 0 0.47028 0.23152 2.031 0.176
halleri - arenosa == 0 0.38960 0.23470 1.660 0.345
ratkovo - arenosa == 0 -0.99420 0.23469 -4.236 <0.001 ***
halleri - columbiana == 0 -0.08068 0.23470 -0.344 0.986
ratkovo - columbiana == 0 -1.46448 0.23469 -6.240 <0.001 ***
ratkovo - halleri == 0 -1.38380 0.23783 -5.819 <0.001 ***
Many thank for any help