I am analysing some data using a glmer and I want to figure out how to specify the random effects in the model. Basically, every subject underwent 10 trials for 4 consecutive days. I am wanting to investigate how environment, group and day affect the time on the 4 consecutive days. Here is a short summary of what the data looks like:
Subject Environment Sex Br_Status Group Trial Day Time
1 DamELC01 colony female nbr fnbr 1 1 60
2 DamELC01 colony female nbr fnbr 2 1 50
3 DamELC01 colony female nbr fnbr 3 1 15
4 DamELC01 colony female nbr fnbr 4 1 13
5 DamELC01 colony female nbr fnbr 5 1 60
6 DamELC01 colony female nbr fnbr 6 1 15
7 DamELC01 colony female nbr fnbr 7 1 26
8 DamELC01 colony female nbr fnbr 8 1 8
9 DamELC01 colony female nbr fnbr 9 1 8
10 DamELC01 colony female nbr fnbr 10 1 6
The current model set up that I have is:
glmer(Time~Environment*Group*Day + (1|Trial),
data=Exp2_ex,
family = Gamma(link = "log"),
control=glmerControl(optimizer = "bobyqa"))
I currently specified only Trial as a random effect but how would I include Subject as a random effect as well? I know they are crossed and I can include them as (1|Subject) + (1|Trial)
, however I have seen multiple examples on here that they could be included together for example as (1+Trial|Subject)
or (1|Trial:Subject)
? Can someone possibly give me some insight?