0todd0000 / spm1d

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

3-way RM-ANOVA effects order #40

Closed zof1985 closed 8 years ago

zof1985 commented 8 years ago

Hi Todd, I am dealing with a 3-way RM-ANOVA of some EMG data using the following code:

from spm1d.stats.anova.ui import anova3rm

anova = anova3rm(data,A,B,C,SUBJ,True)

As I have understood, the output coming out from each element within the "anova" variable reflects the tests for the factors A,B,C and their interaction. The anova variable is a list with 7 elements, thus I guess that the first three values reflect the tests for the main effects for the factors A, B and C, respectively. However, I don't know the index corresponding to the A*B (or any other) interaction. Therefore my question is: How the interaction effects are sorted? I had a look at previous posts and at the documentation but I did not find an answer to my question.

Many thanks, Luca.

0todd0000 commented 8 years ago

Hi Luca,

Apologies for the lack of clarity, you're absolutely right that the order is ambiguous, and this is something we'll try to make clearer in future versions of the software.

There are brief descriptions of the order hidden away in some of the example files. For example, in: ./spm1d/examples/stats1d/ex_anova3rm.py you'll see that the order is:

titles      = ['Main effect A',
               'Main effect B',
               'Main effect C',
               'Interaction AB',
               'Interaction AC',
               'Interaction BC',
               'Interaction ABC']

You can also access the order in interactive Python by typing:

spm1d.stats.anova3rm?

or you can print the function's documentation string in both interactive and non-interactive Python using:

print( spm1d.stats.anova3rm.__doc__ )

which will yield the output:

    '''
    Three-way ANOVA (repeated measures on all factors).

    :Parameters:
        - *Y* --- (J x Q) numpy array
        - *A* --- (J x 1) vector of integer labels for Factor A
        - *B* --- (J x 1) vector of integer labels for Factor B
        - *C* --- (J x 1) vector of integer labels for Factor C
        - *equal_var* --- If *True*, equal group variance will be assumed

    :Returns:
        - List of seven **spm1d._spm.SPM_F** instances in the following order:
            1. Main effect A
            2. Main effect B
            3. Main effect C
            4. Interaction AB
            5. Interaction AC
            6. Interaction BC
            7. Interaction ABC
    '''

One final place to check for documentation is in the API section at spm1d.org: http://www.spm1d.org/doc/API/stats.html There you should see the same docstring as above.

Last, and a very minor point, you can access all of the functions inside spm1d.stats.anova.ui directly from spm1d.stats, so:

from spm1d.stats import anova3rm

is the same as:

from spm1d.stats.anova.ui import anova3rm

I'd recommend accessing the functions through the spm1d.stats interface because spm1d.stats.anova.ui contains some functions like aov which can be used directly but which are not meant for common use. All functions in spm1d.stats are meant for common use.

Cheers,

Todd

zof1985 commented 8 years ago

Hi Todd,

You have been very helpful.

Many thanks, Luca.