I'm currently running a mixed-effect model using lmer() (lmerTest, specifically so I get p-values), in which I have 'Diet' and 'Time' as fixed effects, and 'ID1' and 'ID2' as random effects. Both Diet and Time are categorical variables, and I would like to compare the 3 diets together at various time points.
Here is my code so far:
library(lme4)
test1=lmerTest::lmer(Myovidiae~Diet+Time+(1|ID1)+(1|ID2), data=virallme4
I'm able to subset out the different time points if I do it this way:
Test1T0=lmerTest::lmer(Myoviridae~Diet+(subset=virallme4$Time=="0")+(1|ID1)+(1|ID2),data=virallme4)
But, when I try to run the lsmeansLT() function that comes with lmerTest, it doesn't like the way I've subset.
I know that I need to contrast my groups somehow and I know there is an argument in lmer() for me to do that. But I have absolutely know idea how to write that code.
Any help would be greatly appreciated!
Edit: this is the lsmeans code I was using, along with the error
> lstestT0=lmerTest::lsmeansLT(Test1T0, test.effs = "Diet")
Error in mat %*% rho$fixEffs : non-conformable arguments
In addition: Warning message:
In model.matrix.default(mt, mf, contrasts) :
variable 'subset = virallme4$Time == "0"' is absent, its contrast will be ignored