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).
When I try to run the full ANOVA
model = ezANOVA(data, dv=voltage, wid=subject, within=.(electrode, channel))
I get the following error:
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.
Best Answer
This issue is described in this post by John Fox - author of the
car::Anova()
function that is used internally byezANOVA()
.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:Due to the singular SSP-matrix, this does not return sphericity-corrected p-values:
Instead, use
anova()
with the multivariate model (shortened output). Test for channel:Test for electrode:
Test for channel:electrode interaction: