I ran a repeated-measures ANOVA in R to look at the effects of treatment (3 different treatment groups), gender, age, and education level on a specific biomarker (continuous variable). The data is in long-form with two time points (baseline and post) corresponding to the id column.
model1 <- lmer(Measure1 ~ Treatment + Gender + Education_Level + Age + (1|id), data=dataset) anova(model11_rma)
I've seen some examples of repeated measures ANOVA that include a time interaction. I just want to make sure that this is correct and is actually testing what I need to test. Can anyone verify that my code looks correct? Also, do I need to conduct Mauchly's Test of Sphericity to verify that the assumptions of the ANOVA have been met? If so, how do I do that in R with the lmer model?
I've also tried to run a repeated measures ANOVA in R using the car package and the ez package as shown below, however, I keep getting errors that tell me I am missing data like the following:
Error in ezANOVA_main(data = data, dv = dv, wid = wid, within = within, : One or more cells is missing data. Try using ezDesign() to check your data.
ezANOVA(data=dataset_3_lfclean, dv=.(Measure1), wid=.(ID), within_covariates.(Age), within=.(Gender,Education_Level), between=.(Treatment), detailed=T, type=3)
Measure1_Response <- with(dataset_3_lfclean,cbind(Measure1[Group==1], Measure1[Group==2], Measure1[Group==3])) mlm1 <- lm(Measure1_Response ~ 1) rfactor <- factor(c("g1", "g2", "g3")) mlm1.aov <- Anova(mlm1, idata=data.frame(rfactor), idesign = ~rfactor, type="III") summary(mlm1.aov, multivariate=FALSE)