[R] Question Mixed-Design Anova in R

Lisa van der Burgh 407600@b @ending from @tudent@eur@nl
Fri Nov 23 11:43:35 CET 2018


Hi Everyone,



I have a question about Mixed-Design Anova in R. I want to obtain Mauchly�s test of Sphericity and the Greenhouse-Geisser correction. I have managed to do it in SPSS:



GLM Measure1 Measure2 Measure3 Measure4 Measure5 Measure6 BY Grouping

  /WSFACTOR=Measure 6 Polynomial

  /METHOD=SSTYPE(3)

  /PLOT=PROFILE(Measure*Grouping)

  /CRITERIA=ALPHA(.05)

  /WSDESIGN=Measure

  /DESIGN=Grouping.



I have tried to replicate this in R:

library("dplyr")

library("tidyr")

library("ggplot2")

library("ez")



PatientID <- c(1:10)

Measure1 <- c(3,5,7,4,NA,7,4,4,7,2)

Measure2 <- c(1,2,5,6,8,9,5,NA,6,7)

Measure3 <- c(3,3,5,7,NA,4,5,7,8,1)

Measure4 <- c(1,2,5,NA,3,NA,6,7,3,6)

Measure5 <- c(2,3,NA,8,3,5,6,3,6,4)

Measure6 <- c(1,2,4,6,8,3,5,6,NA,4)

Grouping <- c(1,0,1,1,1,0,0,1,1,0)

dataframe <- data.frame(PatientID, Measure1, Measure2, Measure3, Measure4, Measure5, Measure6, Grouping)

dataframe$Grouping <- as.factor(dataframe$Grouping)

dataframe



ezPrecis(dataframe)

glimpse(dataframe)



dataframe %>% count(PatientID)



dataframe %>% count(PatientID, Grouping, Measure1, Measure2, Measure3, Measure4, Measure5, Measure6) %>%

  filter(PatientID %in% c(1:243)) %>%

  print(n = 10)



# So, we have a mixed design with one between factor (Grouping) and 6 within factors (Measure 1 to 6).



dat_means <- dataframe %>%

  group_by(Grouping, Measure1, Measure2, Measure3, Measure4, Measure5, Measure6) %>%

  summarise(mRT = mean(c(Measure1, Measure2, Measure3, Measure4, Measure5, Measure6))) %>% ungroup()

View(dat_means)



ggplot(dat_means, aes(c(Measure1, Measure2, Measure3, Measure4, Measure5, Measure6), mRT, colour = Grouping)) +

  geom_line(aes(group = Grouping)) +

  geom_point(aes(shape = Grouping), size = 3) +

  facet_wrap(~group)



ANOVA <- ezANOVA(dat, x, PatientID, within = .( c(Measure1, Measure2, Measure3, Measure4, Measure5, Measure6)),

                    between = Grouping, type = 3)



print(ANOVA)





However, this does not work. I know I am probably doing it completely wrong, but I do not know how to solve it. Besides that, I do not know what to fill in at the �x�.

Can somebody help me?



Thank you in advance.

Lisa


	[[alternative HTML version deleted]]



More information about the R-help mailing list