# Solved – How to specify multiple random slopes in glmmPQL (MASS package)

I would like to specify more than one random effect in a generalized linear mixed model with glmmPQL (MASS package). Currently I am using the data from Heck, Thomas and Tabata (2012).

So what I would like to achieve is to prove, if the slopes of the level 1-predictors (femal, minor and lowses) vary between the level 2 units.

Is this the right code to do so?
If not – How can I specify multiple random effects simultaneously?

``PQL<-glmmPQL(readprof~female+minor+lowses+schcomp+smallsch, random=(~1|schcode/minor/female/lowses), family = binomial(link = logit), data = Heck) ``

Many thanks!

Contents

So what I would like to achieve is to prove, if the slopes of the level 1-predictors (femal, minor and lowses) vary between the level 2 units.

I'm new to glmmPQL and mixed-effects models, and I"m not entirely sure what you mean by "level 2 units" here, so I can't check that your model is constructed properly. However, I think I can help you with your question:

How can I specify multiple random effects simultaneously?

According to the glmmPQL documentation, you need to create a matrix of the formulas to input multiple random effects.

``PQL<-glmmPQL(readprof~female+minor+lowses+schcomp+smallsch, random=list(schcode = ~1, minor = ~1, female = ~1, lowses = ~1), family = binomial(link = logit), data = Heck) ``

I found the above info at stackoverflow.

Slashes are used for covariates in a model, rather than just allowing you to input the multiple random effects. You can see how they work in the link.

I hope this helps.

Rate this post