I'm trying to get my head around running more complex mixed models in R (only previously run time-series repeated measures). I have some data from a study where participants completed a series of exercise bouts at two different intensities under two different conditions. Order for condition
was randomised, but within each condition the order for intensity
was the same — 6 bouts alternating between low and high intensity. The below diagram illustrates the data nesting. I'm not quite sure what the term is for the type of relationship between intensity
and bout
, is this a partially crossed/nested?
An example of the current data structure for a participant is below.
pid | condition | intensity | bout | outcome1 | outcome2 | ... |
---|---|---|---|---|---|---|
01 | control | low | 1 | |||
01 | control | low | 3 | |||
01 | control | low | 5 | |||
01 | control | high | 2 | |||
01 | control | high | 4 | |||
01 | control | high | 6 | |||
01 | experimental | low | 1 | |||
01 | experimental | low | 3 | |||
01 | experimental | low | 5 | |||
01 | experimental | high | 2 | |||
01 | experimental | high | 4 | |||
01 | experimental | high | 6 |
Initially I analysed this with a repeated measures ANOVA with bout
coded as 1, 2, 3 for the first, second and third bouts within each intensity. However, I know there is a main effect of bout
and a bout*intensity
interaction for several outcome variables, hence I don't think this approach is optimal.
Using R
and lme4
, how would I structure the formula to model the relationship between bout
and intensity
to best reflect how the participants actually completed the exercise session? For now I've only run the model including the factors as fixed effects and participant ID as the grouping variable. Ultimately, I want to know whether an outcome variable (e.g., outcome1
) changes across bouts, both within each intensity
and within each condition
.
library(lme4)
model1 <- lmer(outcome1 ~ condition * intensity * bout + (1 | pid), data = data)
bout
encoded in R? Is it numeric or a factor? $\endgroup$