Mixed ANOVA with replication but no repeats

#1
Hi,

I try to run Mixed ANOVA with replication but with no repeats (student may go only to one class)
ID- student id
CL - class A1 or A2 - random effect
GEN - gender - fixed effect

How do I do with ezANOVA, or any other function?

It seems that it expect the ID to appear more than once (repeats)
It worked when the ID isn't unique , but not when student appears only in one class (unique ID)

Code:
> ID = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
> CL = c("A1","A1","A1","A1","A2","A2","A2","A2","A1","A1","A1","A1","A2","A2","A2","A2")
> GEN = c("B1","B1","B1","B1","B1","B1","B1","B1","B2","B2","B2","B2","B2","B2","B2","B2")
> DV = c(72,63,73,64,93,85,79,66,95,46,85,89,77,69,65,96)
> df2 <- data.frame(ID,CL,GEN,DV)
> ezANOVA(data=df2, dv=DV, wid=ID, between=GEN, within=CL, type=1 )
Warning: Converting "ID" to factor for ANOVA.
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.
When I tried anova_test
Code:
> ID = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
> CL = c("A1","A1","A1","A1","A2","A2","A2","A2","A1","A1","A1","A1","A2","A2","A2","A2")
> GEN = c("B1","B1","B1","B1","B1","B1","B1","B1","B2","B2","B2","B2","B2","B2","B2","B2")
> DV = c(72,63,73,64,93,85,79,66,95,46,85,89,77,69,65,96)
> df2 <- data.frame(ID,CL,GEN,DV)
> library(rstatix)
> Model1 <- anova_test(
+     data = df2, dv = DV,
+     between = GEN, within = CL, wid=ID
+ )
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
  contrasts can be applied only to factors with 2 or more levels
@Dason, do you have any idea? thanks
 
Last edited: