I am having trouble figuring out the proper syntax for my experiment's mixed effect model.
I used the
Cosinor package in R to determine the amplitude value of each participant, based on heart rate per day across a 24 hour period.
- Data was collected for every day for 6 weeks per subject.
My data looks like this:
User.ID HR Weekday YearDay MESOR amp acr Group TimePoint 39584 71.90667 Sat 300 84.71963 2.021602 -5.172755 Decrease POST 23490 94.12552 Fri 131 86.28663 12.085945 -1.662759 Decrease POST 39085 111.63322 Tue 296 112.87266 18.368315 -1.316736 Decrease POST 24138 68.08333 Tue 156 87.90074 9.807492 -3.470958 Decrease POST 23490 77.02765 Thu 151 102.51004 12.616990 -3.576744 Decrease POST
- There are Pre and Post timepoints, and there are either Increase or Decrease per group assignment.
My goal is to determine if amplitude (amp - from the
cosinor() function output) is predicted by group, timepoint, and day of the week.
So my simple model is:
simple.model <- lm(amp ~ Group * TimePoint + Weekday, data = DF)
For my mixed model, I added a user random effect, so:
mixed.model <- lmer(amp ~ Group * TimePoint + Weekday + (1 | User.ID), data = DF)
My questions are:
- How do I control/model for the weekday?
- Is it nested, because each user perceives the same weekday differently, or is it crossed, because Monday to me, is Monday to you?
- Can I add a random slope, in which case should it be for TimePoint (pre vs postcondition)?
- Although, since Pre/Post is only two levels, it shouldn't be random?