[R-sig-ME] Removing random correlation parameter for categorical variable in lmer
Henrik Singmann
singmann at psychologie.uzh.ch
Mon Jan 18 14:00:52 CET 2016
Yet another possibility is to use the lmer_alt function from my afex
package. It transform a categorical variable into a model matrix of
numerical variables prior to fitting the model and then passes the so
created model matrix to lmer/glmer. This completely suppresses all
correlations among random effects as long as the "||" syntax is used. So
in your case something along the following lines should work:
require(afex)
lmer_alt(Response_time ~ relatedness + mean_response_time +
(relatedness || subject) + (1 | word) + (1 | group))
Hope that helps,
Henrik
Am 17.01.2016 um 02:04 schrieb Ben Bolker:
> Douglas Bates <bates at ...> writes:
>
>>
>> For a numeric covariate x, the model expression 0 + x produces a model
>> matrix with a single column so you can suppress the correlation by using
>> terms like (1 | subject) + (0 + x | subject). However, for a categorical
>> covariate like relatedness with 2 levels the expressions (g | subject), (1
>> + g | subect) and (0 + g | subject) are equivalent in terms of the
>> predictions from the fitted model. The only difference between the last
>> two is in the "contrasts" that they generate.
>>
>> If you really want independent random effects for intercept and for the
>> effect of relatedness you should convert the relatedness factor to a
>> numeric covariate. One possibility is (1 | subject) + (0 +
>> I(as.integer(relatedness) - 1) | subject).
>
>
> Another (equivalent but more readable) possibility is to use the dummy
>
> (1|subject) + (0+dummy(unrelated,"1"))
>
> (I *think* this is right -- if I am reading correctly, you have
> a categorical variable coded as "0", "1", which is a little confusing ...
>
More information about the R-sig-mixed-models
mailing list