I have data of an experiment where subjects (ID
) have to perform 10 trials
of a go/no-go task. I want to study the influence of the decision
(go/no-go) on some physiological measure (e.g. pupil.diameter
) during trial. I want to study that alongside other variables, some dependant on the subject (e.g. age
), and other dependant on the trial (e.g. difficulty
).
My data looks like this:
ID trial decision pupil.diameter age difficulty
0 1 1 go 3.2 47 easy
1 1 2 go 2.4 47 hard
2 1 3 no-go 5.6 47 hard
3 1 4 go 5.1 47 hard
. . . . . . .
9 1 10 go 3.4 47 easy
10 2 1 no-go 3.6 29 easy
11 2 2 go 4.2 29 hard
. . . . . . .
I would originally perform (under R
) linear model/anova analyses like this:
pupil.diameter ~ age + difficulty + decision
with possibly interaction effects.
The problem is that some of my variables are dependant either on the ID
or the trial
(and thus their values repeated across multiple lines).
My search led me to consider a mixed-effects model and to use lmer
, but I am still confused on how to do it correctly.
Is a mixed-effects model suitable here?
How to specify the random effects correctly?
Should I declare my model like this?
pupil.diameter ~ age + difficulty + decision + (1|ID)
Or like this???
pupil.diameter ~ age + difficulty + decision + (1|trial)
pupil.diameter ~ age + difficulty + decision + (1|ID) + (1|trial)
pupil.diameter ~ age + difficulty + decision + (age|ID) + (difficulty|trial)
NB: To generalise the example:
subject-dependant variables could also be categorical (e.g.
gender
);trial-dependant variables could also be continuous (e.g.
difficulty
on a scale of 1 to 10);variable to explain could also be categorical (e.g.
blinked.during.trial?
) and the model would be adapted to a logistic regression;etc.