[R-sig-ME] Model failed to converge when a factor is centered or releveled

Phillip Alday ph||||p@@|d@y @end|ng |rom mp|@n|
Tue Mar 12 17:21:12 CET 2019


A few general comments without looking at your data:

1. It generally doesn't make sense to "center" a categorical variable.
For a two-level, dummy-coded variable you could in theory do this, but
it would lead to a rather odd balance-weighted contrast coding.

2. I have occasionally seen weird behavior in complex binomial models
where the choice of reference-level makes a difference in convergence. I
suspect this has to do with the whether the model is able to "pull away"
from a "solution" where the model just predicts the same response for
everything, but I have not investigated this rigorously nor I have
checked that my hand-waving explanation makes sense in terms of the
actual behavior of the optimizer.

If you really want to reverse your contrast labels, what happens when
you do that directly instead of releveling?
i.e.

c1 <- c(-0.5, 0.5)
contrasts(df$Memory) = cbind(c1)
model_center <- glmer(ACC ~ Memory * Group + (1|Subject) +
(1+Memory|item), family = "binomial", data = df)

c2 <- c(0.5, -0.5)
contrasts(df$Memory) = cbind(c2)
model_relevel <- glmer(ACC ~ Memory * Group + (1|Subject) + ...


Best,
Phillip

On 10/3/19 3:26 am, Chao Han wrote:
> Hi all,
> 
> I'm running a mixed-effects model using lmer4::glmer() function. The
> modeling works with R's default dummy coding. But if I center or relevel a
> factor of 2 levels, the model failed to converge. I am wondering why.
> 
> Here is the data:
> https://www.dropbox.com/s/ysw5rvxowamucoh/example.csv?dl=0
> 
> Here is the code for the model without centering or releveling the factor
> "Memory":
> 
>> model_default <- glmer(ACC ~ Memory * Group + (1|Subject) +
> (1+Memory|item), family = "binomial", data = df)
> 
> The model converges with the above code. But the following model failed to
> converge after centering the factor "Memory":
> 
>> c1 <- c(-0.5, 0.5)
>> contrasts(df$Memory) = cbind(c1)
>> model_center <- glmer(ACC ~ Memory * Group + (1|Subject) +
> (1+Memory|item), family = "binomial", data = df)
> 
> If I relevel the factor "Memory", the following model failed to converge
> either:
> 
>> df$Memory <- factor(df$Memory, levels = c("Y", "X"))
>> model_relevel <- glmer(ACC ~ Memory * Group + (1|Subject) +
> (1+Memory|item), family = "binomial", data = df)
> 
> Why would centering or releveling a factor make a difference in terms of
> convergence? Which result should I trust?
> 
> Thank you in advance for your help.
> 
> Best,
> Chao
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



More information about the R-sig-mixed-models mailing list