[R-sig-ME] random intercept or nested random?
Julia Chacon Labella
juliachacon at gmail.com
Sat Feb 17 11:54:56 CET 2018
Hello to everybody,
I have read that in some cases the same variable could be consider either a
random or a fixed effect at the same time. But do not have any example for
this. Could someone explain me when is this the case? When there is a
justification to considered a variable in fixed effect term of the model
and also in the random part? I am quite interested on that.
I am thinking in the next example:
Imagine we are interested in knowing if the exam marks of pupils depends on
their Sex. So, you choose two different schools to check for this, but
School 1 is only for boys and School 2 is only for girls. Within each
school you sample many classes.
So, we would have ExamMarks as response variable.
SchoolSex as explanatory variable (in this given example would be the same
School or Sex), with two levels SchoolBoys and SchoolGirls
Class as explanatory variable, with many levels (8 per school), coded as
Class1, Class 2....up to Class16.
The model would be (lme4):
lmer(exammarks ~ Schoolsex + (1|Class), data=data)
So, we treat class as a random factor.
Should we consider in this case, the random part of the model as a nested
random and specify it as (1|Class|Schoolsex) ?
In that case the model would be:
lmer(ExamMarks ~ Schoolsex + (1|Class|Schoolsex), data=data)
Thank you very much,
Julia
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list