# GLMM multilevel (hierarchical) model

I want to study the classroom and the school effect/result on the pupil's success (or not) at school. I also want to know the effect of the age, the gender (of the pupils) and if the pupils have or not repeated 1 year school on the pupil's success (or not).

The pupil's variables are : - the age, (11 or 12) - the gender, (male or female) - if they have repeated one year, (yes or not) - the success, (yes or not)

The other variables are : - the classroom they belong to, (A or B) - the school they belong to, (C or D)

I would like to proceed by GLMM, more precisely a multilevel (hierarchical) model using R on my dataset knowing that firstly I am looking for the effect of the classroom and the effect of the school on the pupil's success (or not) and secondly I want to know the effect of the age, the gender and if the pupils have (or not) repeated one year ? Many thanks for your help !

• Sounds like you know exactly what you want to do. What's stopping you for building the model? – charles Jan 12 '14 at 17:25
• In addition to what charles said, there are some excellent threads in this forum on how to use lme4. (eg. stats.stackexchange.com/questions/31569/… and/or stats.stackexchange.com/questions/40670/… ) – usεr11852 Jan 12 '14 at 18:25
• Hi Charles and user11852, Thanks for your comments. Yes I guess I know what I want to do, but I don't know how to do it using R. That is my problem. Thanks for your help ! – varin sacha Jan 12 '14 at 20:52
• In a less technical and more general note: if you only have two classes and two schools, there's not much point to building a mixed model, you should probably just use a regular generalized linear model with school and classroom within school as fixed effects. See glmm.wikidot.com/faq ... – Ben Bolker Jan 12 '14 at 21:56

As already pointed out by Ben Bolker, I think a GLMM might not be the adequate analysis strategy for you, although it might seem appropriate at first due to the nested structure of classes in schools. However, as the lme4 faq tells you:

One point of particular relevance to 'modern' mixed model estimation (rather than 'classical' method-of-moments estimation) is that, for practical purposes, there must be a reasonable number of random-effects levels (e.g. blocks) — more than 5 or 6 at a minimum.

As you have only two levels, for your random factor school and only two or four levels for class, running a glmm will not work properly.

Simply run a binomial glm on your dv, e.g.:

m1 <- glm(success ~ age + gender + repeated + school * class, family = binomial,
data = your.df)
summary(m1)

• Hi, Many thanks Ben Bolker and Henrik for your response. I will apply a binomial glm. Best – varin sacha Jan 13 '14 at 16:04
• Hi, one last thing, supposing that I had more than 6 random effect levels, I should use a GLMM model. How could I do my GLMM model using R ? Thanks ! – varin sacha Jan 13 '14 at 22:41
• @varinsacha This is not a trivial question and cannot be answered in the comments. Please ask a new question for this and make sure to include a minimal working example. This is probably necessary. – Henrik Jan 16 '14 at 15:14
• Hi Henrik, thanks once more for your response. I have just posted my GLMM problem with R Thanks for your help ! – varin sacha Jan 17 '14 at 18:49