[R-sig-ME] Specification of Random structure in glmer()

João Veríssimo j|@ver|@@|mo @end|ng |rom gm@||@com
Thu May 18 14:05:51 CEST 2023


Sorry, typo. For 0 + A*B that should read:
cell A1/B1 ("AA1")
cell A2/B1 ("AA2")          <- had typo in previous reply
B2 - B1, for A1 ("BB2")
interaction ("AA2:BB2")


On 18/05/2023 12:59, João Veríssimo wrote:
> - With treatment contrasts, the formula 0 + A * B yields the following 
> estimates (this holds for the fixed or random effects):
> cell A1/B1 ("AA1")
> cell A1/B2 ("AA2")
> B2 - B1, for A1 ("BB2")
> interaction ("AA2:BB2")
>
> - The formula 1 + A*B yields:
> cell A1/B1 ("(Intercept)")
> A2 - A1, for B1 ("AA2")
> B2 - B1, for A1 ("BB2")
> interaction ("AA2:BB2")
>
> So only one of the estimates is different in the two models, and only 
> for that one you get the relationship that you were expecting.
>
> João
>
> On 18/05/2023 12:09, Tibor Kiss via R-sig-mixed-models wrote:
>> Dear List Members,
>>
>> I am somewhat confused about the random structures of two models. I’ll try to explain the problem without the code, which is available athttps://github.com/Linguistic-Data-Science-Lab/SimRandom.
>>
>> I am assuming a binomial model with glmer with random slopes for subjects for two treatment coded factors (A, B) with two values (A1, A2, and B1, B2, respectively, A1 and B1 being reference levels) and their interaction as follows:
>>
>> M1: glmer(CHOICE ~ A * B + (0 + A * B | subjects) + (1 | items), data = ..., family = …)
>>
>> For this model, I am getting a random values for all four combinations A1B1, …, A2B2 for the subjects.
>>
>> I have also defined another model, which only differs from the first one in the treatment of the intercept in the random structure:
>>
>> M2: glmer(predicted_value ~ A * B + (1 + A * B | subjects) + (1 | items), data = ..., family = …)
>>
>> Now I would expect that the random slopes for the two models are related as follows (illustrated here for A2B1):
>>
>> random slope for A2B1(M1) = random intercept for A1B1(M2) + random slope for A2B1(M2)
>>
>> This works out for the random intercept and the first random slope in M2. As an illustration consider the first subject:
>>
>> A2B1(M1) = -0.05; intercept(M2) = 0.11, A2B1(M2) = -0.16.
>>
>> Now I would expect that these equivalences hold for the other random slopes as well, but the values for the random slopes of A1B2 and A2B2 are identical in both models.
>>
>> I would have expected A1B2(M1) = A1B1(M2) + A1B2(M2), but instead, it is A1B2(M1) = A1B2(M2).
>> I would also have expected A2B2(M1) = A1B1(M2) + A2B1(M2) + A1B2(M2) + A2B2(M2), but again, what I get is A2B2(M1) = A2B2(M2).
>>
>> My question is: is my specification of the models wrong or is there something else that I have missed?
>>
>>
>> Thank you very much
>>
>>
>> Tibor
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org  mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> -- 
> *João Veríssimo*
> Assistant Professor | /Professor Auxiliar/
> School of Arts and Humanities | /Faculdade de Letras/
> University of Lisbon | /Universidade de Lisboa/

-- 
*João Veríssimo*
Assistant Professor | /Professor Auxiliar/
School of Arts and Humanities | /Faculdade de Letras/
University of Lisbon | /Universidade de Lisboa/
	[[alternative HTML version deleted]]



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