My dataset (long format) contains of data collected in 4 studies. Although the variables in the studies were identical, I want to account for the heterogeneity of the population between these studies and thus treat "study" as a random effect.

In the study, participants made 25 binary choices (0/1). I want to test, whether attitudes and trait self-control predict making choice 1.

Thus, my logistic regression model should account for the fact that one subject made 25 decisions and that the subjects were nested within one study.

I would suggest the following: model <-glmer(depvar ~ attitude + selfcontrol + (1 | subject) + (1 | study), data = df, family = binomial("logit"))

Is that correct? Thank you for any advice!

  • 1
    $\begingroup$ Please register &/or merge your accounts (you can find information on how to do this in the My Account section of our help center), then you will be able to edit & comment on your own question. $\endgroup$ Feb 28, 2020 at 7:30

1 Answer 1


Welcome to the site anwyy! Your model looks like it will give you exactly what you want. The big question is whether it makes sense to have a random intercept with just four levels. This is something that is certainly doable within maximum likelihood estimation, and is especially viable if using a Bayesian approach where you put some "restrictions" on the shape and variance of the random intercept through your prior specification. Worst case scenario is that if you use glmer with that small number of levels for year, the random intercepts are likely to have a lot of uncertainty (expressed as standard errors of the Empirical Bayes predictions).

The other option to consider is the so-called "no pooling" approach, which is to add study as a categorical predictor to the fixed effects part of the model. This has the effect of turning the coefficients on attitude and self-control into within-study estimates if these vary within studies.

For example, "within a study, on average, the log odds of the dependent variable increases/decreases by XX with a 1 unit increase on self-control."


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.