I am working with a mixed-effect logistic regression with two independents (a and b, dummy coded 0 or 1), which have a fixed effect for a, b and the paired interaction as well as a random effect of M on these three effects:

glmer(dep ~ a+b+a:b + (1 +a+b+a:b |M), data = df, family = binomial)

I found that the random effect of for the a:b interaction is strongly correlated (~.8) with both a and b random slope effects. But - when changing the coding for the independents (say -.5 to .5 instead of 0 and 1) these correlations are reduced dramatically.

Why is this happening? Anyone knows? What will be the correct way to center in a mixed effect regression? Reduce the mean for each score relative to the total mean of the whole data or the mean for the random effect condition (in my case - each level of M)? My guess is the later - but not sure...

Thank you! Nitzan.


The coding you are doing is called effects coding (centering the Dummy coding). The interpretation of the coefficients is different when you use effects coding, which will cause the correlation with the coefficients to change.

This FAQ from UCLA summarizes the problem better than I can

Why use effect coding?

Here’s a good question, why use effect coding instead of dummy coding? If you have several categorical variables in a model it often doesn’t make much difference whether you use effect coding or dummy coding. However, if you have an interaction of two categorical variables then effect coding may provide some benefits. The primary benefit is that you get reasonable estimates of both the main effects and interaction using effect coding. With dummy coding the estimate of the interaction is fine but main effects are not “true” main effects but rather what are called simple effects, i.e., the effect of one variable at one level of the other variable. This is why most analysis of variance programs use some type of effect coding when estimating the various effects in an ANOVA model.

In terms of how it can effect correlation, you can look at the interaction for dummy coding vs effects coding.

In dummy coding, the coefficients for Positive Positive condition is for 1*1=1. This will be run in contrast to the coefficients for Negative Negative condition 0*0=0 which is the same as Negative Positive(1*0=0) and Positive Negative (0*1=0).

In Effects coding, the coefficients for Positive Positive 0.5*0.5 = 0.25 and Negative Negative = -0.5*-0.5 = 0.25 will be computed together against the Negative Postive and Positive Negative (-0.5*0.5=0.5*-0.5 = -0.25) conditions.

Since the main effect and interaction coefficients in effects coding are estimating different things than dummy coding (and they are interpreted differently), there is no reason why the correlation would remain the same.

Whether effects coding should be done or not for mixed-effect regression depends on the research intent, which is the same as for regular regression. Effects and dummy coding carry the same information, it's a matter of interpretation that determines which to use.

  • 1
    $\begingroup$ @nitzan shahar I edited my answer to address your comment. 1. A linear transformation between the coefficients of dummy and effects coding cannot be made. This means the correlations between the sets of coefficients will not be the same. 2. Deciding on centering is the same for mixed effect regression as regular regression, and depends on the problem $\endgroup$ – Underminer Jul 17 '18 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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