What R function should I use to build the appropriate logistic regression model if I have the following structure?

Independent variables

  1. A categorical variable that varies between-subjects
  2. A categorical variable that varies within-subjects
  3. Another categorical variable that varies within-subjects

Dependent variable

  1. Categorical variable with 2 possible outcomes: TRUE vs. FALSE


In addition to these, participants and test items will be treated as random effects.

I'm lost and I would really appreciate some help.


1 Answer 1


It sounds like you are interested in fitting a mixed effects (binary) logistic regression model. You'll likely need to recode your dependent variable so that it takes the value 0 (instead of FALSE) and 1 (instead of TRUE). Your model will include crossed random effects for participants and items.

The R function that you need to fit this type of model is the glmer function from the lme4 package.

See this link for a detailed example of glmer's use in a setting similar to yours: http://people.linguistics.mcgill.ca/~morgan/book/mixed-effects-logistic-regression.html.


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.