I am trying to decide what is the right random effects structure for my given experimental design. I've read quite a few of the other posts regarding linear mixed effects models and have come across papers like the Barr et al., 2013 paper suggesting to use the maximal random effects structure for confirmatory hypothesis testing. However, for the random effects structures that I am deciding between, I have not come across a representative example and would love to get input from others more experienced with LMEs.
For context, I have a study with 15 subjects. Each subject (on a different day) conducts a task with a different pair of shoes on. I have 5 different pairs of shoes (treated as a categorical variable A,B,C,D,E). They conduct the task multiple times in the morning and multiple times in the afternoon. I want to understand how the pair of shoes and time of day ultimately impact their performance on the task.
Since my two factors of interest are the shoe and time of day I have been treating those as fixed effects. I know there is subject variability, so I have also been including a random intercept term for each subject. However, the shoes and time of day might have a different effect on each subject, so I have been thinking I should include a random slope for these terms as well. Then, my formula would be:
Y ~ Shoe + TimeOfDay + (Shoe + TimeOfDay | Subject)
I generally think this makes sense, but the only concern I have is that because the subject wears a different shoe on a different day, there might be some variability from day-to-day. So instead, I have been thinking of the following random effects structure to capture that:
Y ~ Shoe + TimeOfDay + (TimeOfDay | Shoe:Subject)
Now my grouping variable would be every combination of shoe/subject (essentially each day). And I am saying that each day, the time of day could have a different effect.
My core question is: Can I have a random effects structure like the latter? Where I have a fixed effect also used as part of a grouping variable in a random effect? It seems weird to me to look at variation across days as a random effect when part of the variation across days is what I am interested in capturing as part of the "Shoes" fixed effect. Given my design, are there any suggestions on how to decide between the two random effects structures that I am considering?
fitlmefunction which uses Wilkinson's notation for defining the model equation: https://www.mathworks.com/help/stats/fitlme.html. Specifically, usingShoe:Subjectshould consider the independent interaction between Shoe and Subject. However, I am still concerned whether including a random intercept for the combination of shoe/subject is misinformed if I also have a Shoe fixed effect – rhingo3 Nov 12 '23 at 16:50(TimeOfDay | Subject:Shoe). In MATLAB, the notationSubject:Shoemeans that I will have a random intercept for each combination of subject and shoe. I am not familiar with R notation, but my guess is that the full model structure in R would be something like:Y ~ Shoe + TimeOfDay + (TimeOfDay | Subject/Shoe). As you will see, Shoe is both a fixed effect and part of the random intercept grouping – rhingo3 Nov 13 '23 at 05:33:operator here shows the combination of both random effect clusters here in the way you describe for Matlab (it will display all combinations of both). The/operator also adds the overall intercept of Subject, so if you are only interested in the Subject by Shoe combinations then you can just specify it with:instead of/. – Shawn Hemelstrand Nov 13 '23 at 05:54