Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running scipy's oneway anova in a script

I have a problem. I want to run the scipy.stats f_oneway() ANOVA in a script that loads a data-archive containing groups with numpy arrays like so:

archive{'group1': array([ 1, 2, 3, ..., ]),
        'group2': array([ 9, 8, 7, ..., ]),
        ...}

Now my problem is that the number of groups is not fixed for different data-archives. In other words, I don't know beforehand, how many groups there are in an archive (and also not necessarily what their names are).

The scipy implementation of a oneway ANOVA only accepts comma delimited arrays as input like so:

a = array([ 1, 2, 3, ..., ])
b = array([ 9, 8, 7, ..., ])
c = array([ 5, 6, 4, ..., ])

scipy.stats.f_oneway(a, b, c)

I tried to give it lists, tuples, multidimensional arrays all without success. So presently, the only way I can use this ANOVA implementation is by manually entering the group variables each time which effectively makes it impossible to run this in a script. I am wondering if one of you has an idea how to solve this or how to avoid these very specific data format requirements of f_oneway().

like image 643
surchs Avatar asked Oct 02 '12 02:10

surchs


1 Answers

I suppose you should try:

scipy.stats.f_oneway(*archive.values())
like image 90
Michael Avatar answered Nov 06 '22 02:11

Michael