Repeated measures error: morel levels than subjects (balanced design)

460 views
Skip to first unread message

SwaabLab Davis

unread,
May 7, 2013, 9:36:08 PM5/7/13
to ez...@googlegroups.com

I'm having a problem running a repeated-measures ANOVA using ezANOVA.

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.

Any help will be much appreciated.

-Trevor

Mike Lawrence

unread,
May 7, 2013, 10:53:52 PM5/7/13
to ez...@googlegroups.com
I'm actually not sure what's going on mathematically to cause car::Anova() to fail. You might try contacting John Fox (author of the car package) to inquire on this.

As an aside, might I suggest that since your data is spatial in nature (eeg sampled at various points on the head), you might benefit from actually providing that spatial information to your statistics. The mgcv::gam() function. You could do something like:

    start = proc.time()[3]
    fit = gam(
  data = data
  , formula = voltage ~ 
            s( subject, bs = 're' )
            + condition
            + te( 
                latitude
                , theta
                , bs = 'sos'
                , d = 2
                , k = 28
                , by = condition 
            )
    )
    proc.time()[3] - start

Where you recode the electrode identities into their polar spatial coordinates (latitude and theta). Usually eeg data has time as a variable, in which case you'd want:

    start = proc.time()[3]
    fit = gam(
  data = data
  , formula = voltage ~ 
            s( subject, bs = 're' ) 
            + condition 
            + te( 
                latitude
                , theta
                , t
                , bs = c('sos','ts')
                , d = c(2,1)
                , k = c(28,10)
                , by = condition 
            )
    )
    proc.time()[3] - start

Regardless, you could then obtain predictions for either using ezPredict. I happen to be working on code to automate the process of visualizing the resulting predictions; I'll post a link in the next few days ...

Mike

--
Mike Lawrence
Graduate Student
Department of Psychology & Neuroscience
Dalhousie University

~ Certainty is (possibly) folly ~


--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+uns...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ben Amsel

unread,
Apr 17, 2014, 12:17:31 PM4/17/14
to ez...@googlegroups.com
Hi Trevor and Mike:

I've read John Fox's post on why anova() fails in this case. But I'm wondering if either of you have found a solution in R generally, or ez package more specifically, for when the number of within-subjects IV levels is greater than the number of subjects?

Best, 
Ben

Mike Lawrence

unread,
Apr 17, 2014, 1:02:34 PM4/17/14
to ez...@googlegroups.com
Sorry, I'm not aware of any anova-based solutions. A mixed effects model, on the other hand, should handle it just fine.


--
Mike Lawrence
Graduate Student
Department of Psychology & Neuroscience
Dalhousie University

~ Certainty is (possibly) folly ~


--
You received this message because you are subscribed to the Google Groups "ez4r" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ez4r+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages