I have been given a dataset with 750 participants, with information on Age, Location, Gender and the year it was obtained (predictor variables although responses may vary by location so this is a random effect).

For each individual, a number of 0/1 responses were recorded based on items they had purchased in the last 5 years.

I am aiming to assess whether purchases vary by year, gender and age.

My question is: would this be a binomial glmer and how would i go about coding the 0/1 part? And if so, would i have to test each item individually?

Some example items are car, television, and more location specific items such as pool cleaner.


  • $\begingroup$ As described, this is just a logistic regression problem. No need for random effects. $\endgroup$
    – Eoin
    Commented Jul 2, 2020 at 11:07
  • $\begingroup$ @Eoin there is clustering by location, so radom intercepts would be a good way to handle that. $\endgroup$ Commented Jul 2, 2020 at 13:56

1 Answer 1


There is clustering of observations within location, so one approach to this problem is to fit a seperate generalised linear mixed effects model for each item, with random intercepts for location. In particular you could use a logistic model. If using glmer you would specify family = binomial(link = logit).

Perhaps a better aprroach would be to combine each participant's purchases by summing over the invividual items, to produce a count variable. You could then run a single glmm model which would be a poisson model using family = poisson(link = log). This would have the advantage of using all the data in a single model so it would have more statistical power, the downside is that it would not provide any inference regarding individual items. You would need to check for zero inflation and over/under dispersion which would indicate a more complex model if present.

  • $\begingroup$ Hi, thank you for your response. I have tried the following code: glmer1 <- glmer(formula= Car ~ Year + Age + Gender + (1|Location), data = data1,family = "binomial"(link="logit")) However the following error appears: boundary (singular) fit: see ?isSingular How do i adjust to fix this error? $\endgroup$
    – sinsam23
    Commented Jul 3, 2020 at 13:05
  • $\begingroup$ @sinsam23 that indicates there may not be much correlation within locations for cars so you may not need a mixed model for cars. $\endgroup$ Commented Jul 3, 2020 at 13:37

Your Answer

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

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