[R-sig-ME] Problem specifying uncorrelated random intercepts and slopes for a multi-df covariate

João Veríssimo j|@ver|@@|mo @end|ng |rom gm@||@com
Wed Aug 3 23:30:12 CEST 2022


(1+x2 || id) is shorter notation for (1 | id) + (0 + x2 | id ).
And because x2 is a factor, suppressing the intercept leads to the 
'cell-mean coding' of x2: what is being estimated is the between-id 
variation around the means of each level, A, B, and C (and their 
correlation).

In order to get what you want, turn x2 into two numeric variables 
according to its contrasts. For example:
x2num1 <- ifelse(x2=="B", 1, 0)
x2num2 <- ifelse(x2=="C", 1, 0)

Then (1 + x2num1 + x2num2 || id) will give you the random intercept, two 
random slopes and no correlations.

João

On 03/08/2022 21:10, Juho Kristian Ruohonen wrote:
> Dear List,
>
> This is a logistic GLMM with 1 grouping factor + 8 fixed-effect covariates.
> One of the fixed effects, namely x2, has three unordered categories. This
> is the covariate for whose 2 non-reference categories I want to estimate
> random slopes, along with the random intercepts with which I don't expect
> the slopes to be correlated. But I fail:
>
>
>
> *> VarCorr(glmer(y ~ (x2||id) + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8,
> family = binomial, data = mydata, control = glmerControl(optimizer =
> "optimx", optCtrl = list(method = "nlm")), nAGQ = 1))*
>
>
> *boundary (singular) fit: see help('isSingular')*
>
>
>
>
> * Groups Name        Std.Dev. Corr        id     (Intercept) 0.00000
>         id.1   x2A         0.76331                     x2B         0.75422
>   0.931              x2C         0.56139  0.807 0.967*
>
> ^ Why is it reporting correlations when I told it not to? And why is it
> reporting the intercept variance as zero (which is wholly implausible)? And
> why is it reporting a "random slope" for the reference category of x2? It's
> the reference category, for crying out loud! It's not supposed to get an
> estimate.
>
> Consultation of the lme4 manual
> <https://cran.r-project.org/web/packages/lme4/vignettes/lmer.pdf> (page 7)
> suggests the following alternative syntax for specifying random slopes
> uncorrelated with the random intercepts:
>
> *> VarCorr(glmer(y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + (1|id) +
> (0+x2|id), family = binomial, data = mydata, control =
> glmerControl(optimizer = "optimx", optCtrl = list(method = "nlm")), nAGQ =
> 1))*
>
> *boundary (singular) fit: see help('isSingular')*
>
>
>
>
>
> * Groups Name        Std.Dev. Corr        id     (Intercept) 0.00000
>         id.1   x2A         0.76331                     x2B         0.75422
>   0.931              x2C         0.56139  0.807 0.967*
>
> ^ The exact same strangeness persists. Correlations are being estimated
> against my wishes, and there's a nonsensical parameter supposedly
> ostensibly representing the reference category, plus an implausible zero
> value reported on the random intercepts. What am I doing wrong?
>
> Best,
>
> Juho
>
> 	[[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