I am running a mixed model in R. However I am having some difficulty understanding the type of model I should be running for the data that I have.

Let's call the dependant variable the number of early button presses in a computerised experiment. An experiment is made up of multiple trials. In each trial a participant has to press a button to react to a target appearing on a screen. However they may press the button too early and this is what is being measured as the outcome variable. So for example, participant A may have in total 3 early button presses in an experiment across trials whereas participant B may have 15.

In a straightforward linear regression model using the lm command in R, I would think this outcome is a continuous numerical variable. As well... its a number that participants score on in the experiment. However I am not trying to run a linear regression, I am trying to run a mixed model with random effects. My understanding of a mixed model in R is that the data format that the model takes from should be structured to show every participant by every trial. When the data is structured like this at trial level suddenly I have a lot of 1s and 0s in my outcome column. As of course at a trial level participants may accidently press the button too early scoring a 1, or not and score a 0.

Does this sound like something that needs to be considered as categorical. If so would it then be looked at through the glmer function with family set to binomial?


  • $\begingroup$ I would use a binomial GLMM, your data is exactly the same as accuracy data. $\endgroup$
    – CatM
    Jun 22, 2020 at 20:01
  • $\begingroup$ I agree, that seems to make the most sense. Thanks and appreciated @CatM $\endgroup$
    – Guest
    Jun 23, 2020 at 20:55

1 Answer 1


In this case, you can think of these data as a number of successes out of a total number of trials for each participant, so you can use a binomial glmm, for example, using lme4:glmer:

model <- glmer(cbind(success, total - success) ~ covariates + (1|ID),
       family = binomial, data = mydata)
  • $\begingroup$ Does this answer your question ? If so, please consider marking it as accepted. If not, please let us know why. Thanks ! $\endgroup$ Jul 19, 2020 at 4:50

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.