I use lme function in the nlme R package to test if levels of factor items has significant interaction with levels of factor condition. The factor condition has two levels: Control and Treatment, and the factor items has 3 levels: E1,...,E3. I use the following code:
f.lme = lme(response ~ 0 + factor(condition) * factor(items), random = ~1|subject)
where subject is the random effect. In this way, when I run:
summary(f.lme)$tTable
I will get the following output:
factor(condition)Control
factor(condition)Treatment
factor(items)E2
factor(items)E3
factor(condition)Treatment:factor(items)E2
factor(condition)Treatment:factor(items)E3
together with Value, Std.Error, DF, t-value, p-value columns. I have two questions:
If I want to compare Control vs. Treatment, shall I just use estimable() function in gmodels and make a contrast of (-1,1,0,0,0,0)?
I am interested in whether levels of items, i.e. E1, E2, E3 are different across condition, so I am interested in whether the interaction terms are significant (by just checking the p-value column??):
factor(condition)Treatment:factor(items)E2
factor(condition)Treatment:factor(items)E3
However, how can I tell if factor(condition)Treatment:factor(items)E1 is significant or not? It is not shown in the summary output and I think it has something to do with the contrast used in R... Thanks a lot!
I respectfully disagree with @sven-hohenstein
In R, the default coding for categorial variables is treatment contrast coding. In treatment contrasts, the first level is the reference level. All remaining factor levels are compared with the reference level.
First, the fixed effects are specified here with a zero intercept, ... ~ 0 + .... This means that the condition coding is no longer contr.treatment. If I'm not mistaken, the main effects of Control and Treatment are now interpretable as their respective deviations from the group mean...
In your model, the factor items has three levels: E1, E2, and E3. The two contrasts test the difference between (a) E2 and E1, and (b) E3 and E1. The main effects of these contrasts are estimated for the level Control of the factor condition, since this is the reference category of this factor.
...when the value of items is at its reference level of E1! Therefore:
Control = how much Control:E1 observations deviate from the mean of item E1.Treatment = how much Treatment:E1 observations deviate from the mean of item E1.E2 = how much Control:E2 observations deviate from the mean of item E2.E3 = how much Control observations deviate from the mean of item E3.Treatment:E2 = how much Treatment:E2 observations deviate from the mean of item E2
Treatment:E3 = how much Treatment:E3 observations deviate from the mean of item E3.Thanks for the pointer to estimable, I haven't tried it before. For custom contrasts, I've been (ab)using glht from the multcomp package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With