I recently have been learning how to do mixed models in R (new to both) after being directed to them as a preferred way to analyze my data (originally 2-way repeated measures ANOVA). The study involves EEG recordings of subjects over a period of 6 hours (with a value for each hour) under three different conditions. Each subject participates in each condition.
The model I have looks like this, which I believe is suitable.
lmer(EEG ~ Condition + Hour + (1|Subject)
Now after reading up I know you can obtain post hoc test using lsmeans like this:
lsmeans(model1, pairwise ~ Condition, adjust=”tukey”)
However, this output only shows the post hoc test between Condition A-B, A-C, B-C. With stats software (with two way repeated measures ANOVA anyway) I am able to get the difference by hour like below.
Condition A, Hr 1 – Condition B, Hr 1
Condition A, Hr 1 - Condition C, Hr 1
Condition B, Hr 1 - Condition C, Hr 1
Condition A, Hr 2 – Condition B, Hr 2
Condition A, Hr 2 - Condition C, Hr 2
Condition B, Hr 2 - Condition C, Hr 2
....etc.
I was wondering how I would do the same in R with mixed models. Or if there is some preferred alternative that provides the same info by hour as is classically reported. Thank you for your help in advance.
Update:
I am using lmer from the lme4 package and lsmeans from lsmeans package.
Here is a sample structure of my dataframe (there is actually 3 conditions, 6 hours):
Subject Condition Hour EEG
1 A 1 X
1 A 2 X
2 A 1 X
2 A 2 x
1 B 1 x
1 B 2 x
2 B 1 x
2 B 2 X
I tried (which I previously neglected to mention) lsmeans(model, pairwise ~ Condition | Hour):
But I get 3.5 Hr instead of by hour:
$contrasts
Hour = 3.5:
contrast estimate SE df z.ratio p.value
A - B 0.8042939 3.848262 NA 0.209 0.9762
A - C -5.3425872 3.848262 NA -1.388 0.3470
B - C -6.1468811 3.848262 NA -1.597 0.2468