```Date: Nov 6, 2013 3:53 AM
Author: Tim
Subject: Re: one-way repeated measures ANOVA with more levels than subjects

OK, I have now heard back from the original author of the function. Though this is not stated in the code, the implementation is a MANOVA and not a repeated measures ANOVA.I will now simply implement a repeated measures ANOVA for fieldtrip.Thanks again for your help, your suggestions towards the MANOVA helped solving this riddle.TimOn Friday, October 25, 2013 5:18:01 PM UTC+2, tkie...@gmail.com wrote:> On Thursday, October 24, 2013 1:27:38 AM UTC+2, Jeff Miller wrote:> > > On Thursday, October 24, 2013 10:37:52 AM UTC+13, Bruce Weaver wrote:> > > > > > > For those who are interested, here's the code:> > > > > > > http://code.google.com/p/fieldtrip/source/browse/trunk/statfun/statfun_depsamplesF.m?r=935> > > > > > > > > > > > This part of the code looks suspect to me:> > > > > > > > > > > >   nunits = max(design(cfg.uvar,:));> > > > > >   dfdenom = nunits - ncontrasts;> > > > > > > > > > > > I'm not confident, but it looks to me like:> > > > > > > > > > > >    nunits = the number of subjects.> > > > > >    ncontrasts = (at least by default) the number of df's> > > > > >                  for the repeated measures factor factor.> > > > > > > > > > > > In that case, dfdenom for the factor effect in a repeated measures design should be (nunits-1)*ncontrasts.> > > > Hi Jeff,> > > > Thanks for looking into this. The line you are referring to is the suspicious one (in fact the one that made me wonder whether I had a conceptual misunderstanding here).> > > > Below the line, they compute the actual F statistic with> > > >     for smplindx=1:nsmpls> >         datonesmpl=reshape(dat(smplindx,poslabelsperunit),nunits,nconds);> >         contrasts=datonesmpl*cfg.contrastcoefs';> >         contrastavg=mean(contrasts,1);> >         dev=contrasts-repmat(contrastavg,nunits,1);> >         covmat=(dev'*dev)/(nunits-1);> >         s.stat(smplindx)=nunits*contrastavg*inv(covmat)*contrastavg';> >     end;> > > > Apparently, they are comparing the factor levels to their average, which makes a MANOVA unlikely. I will go and see whether there is something on this in the fieldtrip mailing list. I will keep you updated.> > > > If someone has a suggestion in the meantime, of course please let me know about it.> > > > Thanks again for your help and advice> > Tim
```