I have an experiment with 2 IVs, time (3 levels, t1, t2, t3, within subject), and correction type (3 levels, between subject). DV = attitude (continuous). The complete lmer model looks like this:
agreement ~ correction * time + (1 + time|subject) + (1 + correction + time|item)
How do I get simple effects from the overall model?
I would like to compare all three levels of correction at time point 3, but taking into account the individual participant scores at time point 1 (a baseline measure). This would be kind of like an ANCOVA on time point 3 with baseline scores from timepoint 1 as the continuous measure.
I can do this:
library(lsmeans)
ref_levs <- emmeans(mod2, "correction", by = "time", at = list(time = "t3"))
pairs(ref_levs)
But I cannot have the output of the comparisons that controls for the individual participant scores at t1.
Am I forced to subset the dataset to have what I need, fitting a model like this one?
agreement_t3 ~ correction + time_t1 + (1|subject) + (1 + correction|item)
Or there is a way in emmeans to obtain that without having to subset the dataset?
Though it appears that you want to treat the observation at time 1 as a covariate, I will nonetheless show a reasonable way of estimating change from baseline with the model shown in the OP.
First, set things up so we have time as the primary factor, and obtain contrasts that compare times 2 and 3 with time 1:
emm1 <- emmeans(mod2, ~ time | correction)
emm2 <- contrast(emm1, "trt.vs.ctrl1, name = "time.gap")
Now, time.gap
is a new factor with just the two levels t2 - t1 and t3 - t1. So you can now compare those changes:
pairs(emm2, by = "time.gap")
It's possible to do this in fewer steps: contrast(emm1, interaction = c("trt.vs.ctrl1", "pairwise"), by = NULL)
; but I think the above is less confusing and easier to interpret.