I have a question regarding including my main predictors in the fixed as well as random effects term in a mixed model. I am using R and will provide a sample data set, but I am generally happy for theoretical input on this.
The data set is the following: It's a repeated measures dataset with two different interventions (food and training), each of them have two levels. All participants underwent each combination of conditions. Hormone samples were collected over the course of the day, but in this model I want to focus on the baseline differences. Age and BMI are included as covariates.
ID <- rep(letters[1:16],4) training <- rep(rep(c("T1","T2"),each=16),2) food <- c(rep(c("F1","F2"),each=16),rep(c("F2","F1"),each=16)) hormone <- rnorm(n = 64,mean=5,sd=2) BMI <- as.numeric(rep(sample(18:35,size = 16,replace = T),4)) age <- as.numeric(rep(sample(40:60,size = 16,replace=T),4)) DF <- data.frame(ID,training,food,hormone,BMI,age) indNA <- which(DF$hormone%in%sample(DF$hormone,2)) indNABMI <- which(DF$BMI%in%sample(DF$BMI,1)) DF$BMI[indNABMI] <- NA DF$hormone[indNA] <- NA DF$BMI <- scale(DF$BMI) DF$age <- scale(DF$age)
In order to test for the interaction effect of both intervention types on baseline hormonal differences, I would have liked to setup the following model:
m1 <- lmer(hormone~training*food+age+BMI+(1+training*food|ID),DF)
and test it against this null-model (if you see any flaw in the model setup to begin with, I am of course happy to know):
m01 <- lmer(hormone~training+food+age+BMI+(1+training+food|ID),DF)
However, it is obvious I do not have enough observations to do so.
My questions now are:
Would it be appropriate to reduce the random slopes term to this?
m1red <- lmer(hormone~training*food+age+BMI+(1+training+food|ID),DF)
As pointed out in this post here for example, Minimum number of levels for a random effects factor?, one should have at least 5-6 observations for a random effect to be included. Is this also true for the random slopes per subject (in my case, there are two observations per condition level per subject) and should my random slopes therefore be excluded entirely?