how to model counfounding variable in mixed models? subject <- factor(rep(seq(1,28),each=4))
y <- c(5,4,9,3,4,4,2,1,10,7,8,7,1,2,1,1,5,10,1,7,3,2,1,4,3,8,7,3,1,1,2,1,15,10,20,11,2,2,1,3,11,12,9,7,2,3,1,2,11,9,8,9,3,4,2,1,5,4,8,3,7,6,27,18,1,7,7,6,13,5,8,1,7,11,8,9,3,2,5,3,1,9,7,4,2,1,7,4,15,9,6,7,15,23,1,23,12,1,1,17,2,13,21,23,11,9,2,3,7,6,5,4) 

gender <- factor(rep(c(rep("Female",times=16),rep("Male",times=12)), times=2))
day <- factor(rep(c("day1","day2","day3","day4"),times=28))
score <- factor(rep(c("A","B","A","C","A","C","B","B","C","C","B","B","A","A"), each=4, times=2))
data <- data.frame(sub=subject, y=y, gender=gender, day=day, score=score)

gender is a confounding variable. What is the best model to account for gender when my interest is in the score:day interaction? Should I interact it with other predictors of interest:
m <- lmer(y ~ score*day*gender + (1|sub), data=data)

or simply add it to the model like this:
m <- lmer(y ~ score*day + gender + (1|sub), data=data)


If gender is a confounder then all you typically need to do is add it to the model, as per your 2nd model formula:
m <- lmer(y ~ score*day + gender + (1|sub), data=data)

