[R-sig-ME] lme4 for a 4 level hierarchy

Kim Pearce k|m@pe@rce @end|ng |rom newc@@t|e@@c@uk
Wed Sep 4 13:54:51 CEST 2024


Hello everyone,

If I may, I'd like to ask if I am visualising the correct syntax to use for a hypothetical situation using a mixed effects logistic regression with a 4 level hierarchy.

Say we have nurses which are nested within wards and the wards are nested within hospitals and hospitals are nested within regions of the UK. Each nurse has a binary response recorded (Y). Nurses are at level 1, wards at level 2, hospitals at level 3 and regions at level 4.  Say each ward has one category of an ordered 3 category intervention applied where a higher ordered category of intervention was hypothesised to affect a nurse's binary response.

Hypothetically, I wish to generate a model with a fixed effect for "Intervention" and random (and fixed) intercepts for (i) each region, (ii) each region x hospital combination and (iii) each region x hospital x ward combination.  Would the following syntax be appropriate?

Note intervention appears in the model as a factor below.

m1<-glmer(Y~interventionf+(1|region/hospital/ward),data=data,family=binomial,control=glmerControl(optimizer="bobyqa"))

Many thanks for your views.
Kind regards,
Kim

Dr Kim Pearce PhD, CStat, Fellow HEA
Newcastle University 



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