0todd0000 / spm1d

One-Dimensional Statistical Parametric Mapping in Python
GNU General Public License v3.0
63 stars 21 forks source link

Graphs in two way repeated measures anova #17

Closed bernard-liew closed 9 years ago

bernard-liew commented 9 years ago

figure_1

Hello Todd,

With respect to the "heat map" (think this is what it is called?) produced by the two way repeated measure code, how do we interpret it? In addition, can we produce a typical spm{F} curve similar to that in simpler spm tests.

Regards, Bernard

0todd0000 commented 9 years ago

Hi Bernard, That figure depicts a design matrix (left) and contrast matrices (right). These are unrelated to the results, so you don't need to interpret them unless you're interested in the details of ANOVA computations. The design matrix contains one row per observation and one column per factor-pair (including subject). Please find details here: http://www.fil.ion.ucl.ac.uk/~wpenny/publications/spm-book/anova.pdf

The spm{F} curves are the same in all tests, so I don't quite understand your question. Could you send an example which shows how the spm{F} curves are atypical?

Todd

bernard-liew commented 9 years ago

Hi Todd,

That clarifies... the anova2rm.py code for inference is

(1) Conduct ANOVA:

FF = spm1d.stats.anova2rm(y, A, B, SUBJ,equal_var=True) FFi = [F.inference(0.05) for F in FF] fvalues = [F.z for F in FF] df = [F.df for F in FF] pvalues = [Fi.p for Fi in FFi] print 'Calculated results:' print fvalues print df print pvalues

There after, unlike other methods, it does not have plot codes. I assumed it was

Fi.plot() pyplot.show()

But it produced the error "'list' object has no attribute 'plot'".

Regards, Bernard

0todd0000 commented 9 years ago

Hi Bernard, In two- and three-way ANOVA there are multiple F statistics stored in a single list, and the individual F statistics must be plotted separately. For two-way ANOVA there are three F statistics (two main effects and one interaction effect), so try the following:

FF = spm1d.stats.anova2rm(y, A, B, SUBJ, equal_var=True)
FFi = [F.inference(0.05) for F in FF]
FAi,FBi,FABi = FFi
pyplot.subplot(131);  FAi.plot()
pyplot.subplot(132);  FBi.plot()
pyplot.subplot(133);  FABi.plot()

Todd

bernard-liew commented 9 years ago

Thanks Todd,

I previously asked you on the interpretations of the F values, p values output arrays. I simply followed the code in anova2rm.py

FF = spm1d.stats.anova2rm(y, A, B, SUBJ,equal_var=True) FFi = [F.inference(0.05) for F in FF] fvalues = [F.z for F in FF] df = [F.df for F in FF] pvalues = [Fi.p for Fi in FFi] print 'Calculated results:' print fvalues print df print pvalues

Your solution (which works well) is to print the spm objects

print FAi print FBi print FABi

This is great. Resolved

Regards, Bernard