Let's say I have 40 participants. They are each measured three times. On each visit they see ten stimuli, which can be one of two types. They then get some score for each stimuli. How could I model the effect of stimulus type, session number, and their interaction, with lme4?

I've included some example data, and my best guess at the model with the full random effects structure below.

Thanks!

```
require(lme4)
participant <- rep(1:40, each = 30)
session <- rep(rep(1:3, each = 10), times = 40)
item = rep(1:10, times = 120)
type = rep(1:2, times = 600)
score = rnorm(1200)
data <- cbind(participant, session, item, type, score)
data <- as.data.frame(data)
data$participant <- as.factor(data$participant)
data$session <- as.factor(data$session)
data$item <- as.factor(data$item)
data$type <- as.factor(data$type)
m <- lmer(score ~ type*session+ (1 + type|participant/session) + (1|item/session), data = data)
```

- Serverfault Help
- Superuser Help
- Ubuntu Help
- Webapps Help
- Webmasters Help
- Programmers Help
- Dba Help
- Drupal Help
- Wordpress Help
- Magento Help
- Joomla Help
- Android Help
- Apple Help
- Game Help
- Gaming Help
- Blender Help
- Ux Help
- Cooking Help
- Photo Help
- Stats Help
- Math Help
- Diy Help
- Gis Help
- Tex Help
- Meta Help
- Electronics Help
- Stackoverflow Help
- Bitcoin Help
- Ethereum Help