# What is the appropriate random effect model and R-code for following data and question?

I attached a data here called image_study. The “image_study.csv” dataset contains data from a study examining the speed of classification of two different types of image: artworks, and natural images. There are four variables in the data as follows:

participant – a unique identifier for each participant

image – a unique identifier for each image

image_type – a factor indicating whether a given image is an Artwork or a Natural image.

RT – reaction time in milliseconds

I want to model reaction times (RT) as a function of the other variables in the dataset. The purpose here is to examine the effect of Image-type on RT.

1. Which of the fixed effect, random effect, or mixed effect model modes should I choose?
2. Which participant or image variables should be considered as a random effect in the model?
• @MrFlick I want to know the code related to R software about this question. Jun 5 at 3:59
• You need to choose a model first. R can't tell you which model to use or how to model your data (fix vs random effects). Those are statistical concerns, not programming concerns. You need to know what you want to do before you can write R code to do it. Jun 5 at 4:06
• @MrFlick Both model selection and code writing in R are what I want. I also do not know what model to choose, nor do I know how to run it in R. (I am very familiar with R software). Jun 5 at 4:10
• What do you think is the appropriate model, given your data and question? Jun 5 at 5:22
• @AngelosAmyntas the crossed mixed effect model is the appropriate model for this question. Sep 27 at 10:12

Since you say:

The purpose here is to examine the effect of Image_type on RT.

then we need a regression model with RT and the response and image_type as the main exposure (fixed effect).

Since you have repeated measure within both participant and image then you should fit random intercepts for both of these.

Furthermore, since participant and image appear to be crossed (from the data picture all images were seen by participant 1 and that appears to repeat for participant 2), then the following model should be appropriate:

RT ~ image_type + (1|participant) + (1|image)


which is the syntax you would use with popular R packages such as lme4. eg:

library(lme4)
model <- lmer(RT ~ image_type + (1|participant) + (1|image), data = image_study
summary(model)

• people often use identity-link Gamma models to model reaction time (I don't necessarily think this is a good idea, but they do it): glmer(..., family=Gamma(link="identity")) Jun 6 at 1:45
• @BenBolker what is the default link function and distribution for random effect models? Jun 6 at 4:15
• See here for a discussion about the link function for gamma models Jun 6 at 7:10
• @BenBolker Indeed, I have seen that too, it often seems to arise from poorly fitting linear models, but I'm not sure the gamma models always improve things. For example here, here,and here Jun 6 at 7:54
• @MehdiLoohs generally Gaussian/identity Jun 6 at 15:19