4
$\begingroup$

I am having difficulty understanding how the results from Linear Mixed Effects model. I am examining the three different types of learning condition, condition A, B, and C. My formula using Lme4 package is following:

fit <- lmer (dv ~ condition + (1|id))

I would like to set a model where I compare each learning condition with grand mean. So, I set a sum contrast.

condition <- factor (condition)
contrasts(condition) <- contr.sum(3)
fit <- lmer (dv ~ condition + (1|id))
summary(fit)

However, now I cannot find the condition C in the result. Where can I get the comparison between condition C and grand mean? This is how result supposed to be?

$\endgroup$

1 Answer 1

6
$\begingroup$

contr.sum makes sure all the contrasts sum to zero so that the "intercept" term is the grand mean. The effects are summarized with coefficients representing the number of factor levels ($k$) minus 1. In this case, the last level is dropped. The coefficients represent a mean difference from the "grand mean" for the first $k-1$ factor levels.

If you fit lm(y ~ x - 1) where $x$ has the sum contrast, then the model coefficients are the stratum specific means for each level of $x$, but the inference tests a mean difference from 0 for each level of $x$. This is useless unless $x$ is centered. I suggest you fit this model if you wish to simultaneously test the 3 parameters' difference from the grand mean. Technically speaking, this is overkill since such a model is overspecified, but that isn't inherently a bad thing.

$\endgroup$
4
  • $\begingroup$ Thank you very much, @AdamO! This is a super clear answer. Now I am wondering if I can still use the model without intercept when I insert another factor ‘z’ which has a treatment contrast (dummy coding) i.e., (‘lm(y ~ x + z -1)’ ) . If I am understanding correctly, dummy coding allows intercept to be a mean value for the reference level, which sounds to me prevents from me to fit no intercept model. Could you let me hear your idea on this? Please and thank you! $\endgroup$ Commented Dec 29, 2017 at 21:18
  • 1
    $\begingroup$ @user8460166 the -1 will only affect the first term in the formula. You must format it so that treatment comes first and any blocking variables follow it. If z is a two level block, it will only generate 1 contrast. $\endgroup$
    – AdamO
    Commented Dec 29, 2017 at 21:22
  • $\begingroup$ Wow! I did not known the -1 only affect the first term in the formula! Thank you very much for your help. I really appreciate it. $\endgroup$ Commented Dec 29, 2017 at 22:01
  • $\begingroup$ Hi, @adamO! I tried the -1 and it worked well! But, when I put two factors that have sum contrasts, I cannot compare the levels in the second factors with grand means, and the interaction also lacks each last levels in the both factors even though I specified no intercept model, i.e., lm(y ~ x * z -1) with x and y coded with sum contrast and the both factors have three levels for each). I tried lm(y ~ x * z -1 - 1), but it seems not working. Could you help me out with this too? $\endgroup$ Commented Dec 30, 2017 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.