# Binary variable shows twice in random effects when random intercept excluded [R, lme4]

When I use lmer of lme4 to fit a random one-variable slope model with random intercept excluded, both levels of the one-variable slope are reported with random variances, as if the slope had two variables (i.e., as if it were a three-level treatment effect). How should I interpret this?

## Detailed Example:

Scenario 1
Here is what the model looks like with both random slope and intercept included. Everything works as expected: in line 7, the binary variable Cond1 shows up with just one effect (Cond1hetero, the upper level of the two-level categorical)...

> RT_log.CVquestA.lmer=lmer(RT_log~Cond1+(1+Cond1|Subject),data=basedata)
> summary(RT_log.CVquestA.lmer)
...
Random effects:
Groups   Name        Variance Std.Dev. Corr
Subject  (Intercept) 0.026121 0.16162
Cond1hetero 0.001366 0.03696  -0.47
Residual             0.028667 0.16931
Number of obs: 3321, groups:  Subject, 19

Fixed effects:
Estimate Std. Error t value
(Intercept)  6.57461    0.03725  176.49
Cond1hetero  0.02815    0.01052    2.68

Correlation of Fixed Effects:
(Intr)
Cond1hetero -0.412


Scenario 2
Here is what the model looks like when I remove the random intercept. Note the extra variance term on line 6 of the block below (i.e., we now see an effect for Cond1non-hetero, the reference level of the Cond1 categorical variable, in addition to the upper level Cond1hetero). I don't know how to interpret or use this output!

> RT_log.CVquestB.lmer=lmer(RT_log~Cond1+(0+Cond1|Subject),data=basedata)
> summary(RT_log.CVquestB.lmer)
...
Random effects:
Groups   Name            Variance Std.Dev. Corr
Subject  Cond1non-hetero 0.02612  0.1616
Cond1hetero     0.02184  0.1478   0.98
Residual                 0.02867  0.1693
Number of obs: 3321, groups:  Subject, 19

Fixed effects:
Estimate Std. Error t value
(Intercept)  6.57461    0.03725  176.49
Cond1hetero  0.02815    0.01052    2.68

Correlation of Fixed Effects:
(Intr)
Cond1hetero -0.412

• I don't quite see where the "additional variance term" is. Apparently there are two levels of Cond1 and both are shown in the output, as they should. Nothing extra seems to be present. Why don't you simplify the situation and run the simplest possible regression that involves this variable, something like lm(RT_log ~ 0+Cond1). Does its output make sense or not? – whuber Feb 29 '16 at 15:14
• @whuber, thanks for your input, but, for a two-level categorical variable, only one effect should show in the output, as is the case in the first printout. And, this is the simplest scenario of the phenomenon I am observing. The suggestion you make would target behavior of the fixed effects, not the random effects (which is where the problem is). – clarpaul Feb 29 '16 at 15:19
• Only one effect should show when there is an intercept to account for the base value! My suggestion wasn't meant to imply that lm is an appropriate model, but only to help you see where your misunderstanding lies. I warmly recommend actually running that command and looking at its output. This is not a problem with mixed effects, but with understanding how regression works and how to code categorical variables. – whuber Feb 29 '16 at 15:21
• Thank you. I now see that the variance of the reference level in scenario 2 of my question has the same variance as the Intercept of scenario 1. So, in effect, the intercept is not going away...which is as it should be, now that I think of it more carefully. Thank you, @whuber! – clarpaul Feb 29 '16 at 15:26
• There may be some additional insight available in our answers on dummy-coding categorical variables. Briefly, Cond1hetero means two different things in the two scenarios. In the first, it represents the difference between that level and the base level; in the second, it represents the actual value of that level, rather than a difference. Note the very different correlation coefficients reported in the right-hand Corr column. – whuber Feb 29 '16 at 15:52

You got exactly what you asked for. If you compute models such as ANOVA, regression etc. they by default contain intercept and in vast majority of cases you should not drop the intercept from your model. In models with intercept included, it is a "starting point" (see e.g. here), where all the other parameters describe how the dependent variable behaves given the parameters. If you have categorical variable among the independent variables in your model, then you can estimate effects for $k-1$ out of $k$ levels of such variable, because otherwise your model won't be identifable. If you drop intercept, you estimate effects for $k$ levels since there is no other baseline.

To make the example simpler, I'm going to use as an example mtcars dataset and simple linear regression. As you can see below, model with intercept shows how manual transmission (am=1) influences car's miles per gallon, while model without intercept shows different behavior of cars with automatic or with manual transmission. As there are only two levels in am variable and the model is very simple, there is no substantial difference in both models.

> lm(mpg ~ as.factor(am), data = mtcars)

Call:
lm(formula = mpg ~ as.factor(am), data = mtcars)

Coefficients:
(Intercept)  as.factor(am)1
17.147           7.245

> lm(mpg ~ 0 + as.factor(am), data = mtcars)

Call:
lm(formula = mpg ~ 0 + as.factor(am), data = mtcars)

Coefficients:
as.factor(am)0  as.factor(am)1
17.15           24.39

• Thanks. I now understand the behavior of a fixed effects model on omission of intercept term. I am still perplexed by the behavior in the case of random effects. In particular, I don't understand how to relate the variance (0.02184) of Cond1hetero in Scenario 2 to its variance in Scenario 1 (0.001366), nor do I understand its almost perfect correlation with the other level (Cond1non-hetero). – clarpaul Feb 29 '16 at 18:13
• The reason I'm interested in this is that the only way to remove correlation between the intercept and Cond1 in lmer is to change (1+Cond1|Subject) to (1|Subject) + (0+Cond1|Subject), and this generates these non-obvious variance and correlation structures involving the categorical variable (in this case, Cond1). – clarpaul Feb 29 '16 at 18:15