I'm having a problem running a repeated-measures ANOVA in R using the ezANOVA function.

I have data from 18 subjects - each subject participated in 3 conditions, and data was collected in each subject/condition combination at 29 electrode sites (1566 total data points in a balanced design with no missing cells).

Error in lambda > 0 : invalid comparison with complex values Error in
ezANOVA_main(data = data, dv = dv, wid = wid, within = within, :
The car::Anova() function used to compute results and assumption tests
seems to have failed. Most commonly this is because you have too few
subjects relative to the number of cells in the within-Ss design. It
is possible that trying the ANOVA again with "type=1" may yield
results (but definitely no assumption tests).

Things work fine though if I include fewer levels of electrode than I have subjects (18 or fewer), but if I add more it fails. Why is this a problem? I wouldn't think that having greater-than-n levels for a within-subjects factor would be a problem if it's a balanced fully repeated-measures design. (SPSS will compute things just fine). Using Type I SS works, but if I select this option I won't give me the sphericity corrected p-values that I need to report.

2 Answers
2

This issue is described in this post by John Fox - author of the car::Anova() function that is used internally by ezANOVA().

As a workaround, you can use anova() using a multivariate model specification that is described in this article by Peter Dalgaard as well as in this excellent answer by Aaron. Here's a reproducible example with data in wide format:

I`ve got another "solution" for your problem:
I faced the same error message recently when I analyzed ERPs using a rmANOVA with two factors, one of them being a factor electrode with 26 levels. Fortunately, I remarked that the error message only occurred when I analyzed latencies, but not when I analyzed amplitude values. I took a closer look at my dataset and wondered whether it might be a problem of too many or unequal number of decimal places. I tried to circumvent this problem by simply rounding the decimal places (thus making them all equal).
After doing so, ezANOVA worked again.

So, in your case, try:

$$
data$voltage <- round(data$voltage, digits = 2)

(NOTE: please ignore the two dollar signs ($) in front of the code; I put them there to circumvent that the dollar signs in the code are interpreted as italics)

This code actually means that all voltage values are rounded to two decimal places.

Then perform the ANOVA with ezANOVA. Now it should work (at least it did for me).