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
ezANOVA(data=dataset_3_lfclean, dv=.(Measure1), wid=.(ID), within_covariates.(Age), within=.(Gender,Education_Level),
between=.(Treatment), detailed=T, type=3)
Car
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)
Here's my data in wide-form where each dependent variable (measured at time 1 and time 2 has its own column and each participant has a single row:

Here's my data in long-form where each participant has multiple rows:

?mauchly.testfrom your R session – thelatemail Dec 06 '19 at 00:37mauchly.test(lm(cbind(mpg, disp) ~ 1, data=mtcars))to make a temporary linear model and test it? Obviously adapting to your data rather than the built-inmtcars– thelatemail Dec 06 '19 at 00:45lmer()) to model the data? This model is not exactly equivalent to a repeated measures ANOVA. – statmerkur Dec 08 '19 at 08:29Treatmentat time point 1 and time point 2, you have to construct a different model. What do you mean by "two time points (baseline and post) corresponding to the id column"? Do you mean that data of the same subject (=id) are collected at time point 1 and at time point 2? – statmerkur Dec 09 '19 at 00:31