rogerlew / pyvttbl

Automatically exported from code.google.com/p/pyvttbl
10 stars 8 forks source link

ANOVA - TypeError: can only concatenate list (not "str") to list print(aov) #13

Closed GoogleCodeExporter closed 7 years ago

GoogleCodeExporter commented 9 years ago

bfactors must also be a list: aov = df.anova('dat', bfactors=['AgeGroup',] wfactors=['withinORcross','modality'])


I was wondering if you could help me with the following:

After making a DF,...

   df = pyvttbl_DataFrame()
   df.read_tbl('/home/brain/tmp_csv.csv')

...And then fitting an ANOVA model...

   aov = df.anova('dat', bfactors='AgeGroup',
                         wfactors=['withinORcross','modality'])

...I get a 'TypeError: can only concatenate list (not "str") to list 
print(aov)' error (copied out in full below). 

I believe this may be something to do with the organization and formatting of 
the .csv file, since the ANOVA tutorial example works fine. In this case my 
.csv file was written to file from pandas; not quite sure how that could be the 
problem per se though. 

Thanks very much, 

John

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-147-1f30da5cce82> in <module>()
      2 df = pyvttbl_DataFrame()
      3 df.read_tbl('/home/brain/tmp_csv.csv')
----> 4 aoc = df.anova('dat', bfactors='AgeGroup', wfactors=['withinORcross', 
'modality'])

/usr/local/lib/python2.7/dist-packages/pyvttbl-0.5.2.2-py2.7.egg/pyvttbl/base.py
c in anova(self, dv, sub, wfactors, bfactors, measure, transform, alpha)
   1973         aov=stats.Anova()
   1974         aov.run(self, dv, sub=sub, wfactors=wfactors, bfactors=bfactors,
-> 1975                 measure=measure, transform=transform, alpha=alpha)
   1976         return aov
   1977 

/usr/local/lib/python2.7/dist-packages/pyvttbl-0.5.2.2-py2.7.egg/pyvttbl/stats/_
anova.pyc in run(self, dataframe, dv, wfactors, bfactors, sub, measure, 
transform, alpha)
    643 
    644         # a list of all the factors
--> 645         factors=wfactors+bfactors
    646         self.dftrim=0.
    647 

TypeError: can only concatenate list (not "str") to list

http://pyvttbl.googlecode.com/hg/doc/_build/html/Anova.html#example-mixed-subjec
ts-anova
-- 

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-147-1f30da5cce82> in <module>()
      2 df = pyvttbl_DataFrame()
      3 df.read_tbl('/home/brain/tmp_csv.csv')
----> 4 aoc = df.anova('dat', bfactors='AgeGroup', wfactors=['withinORcross', 
'modality'])

/usr/local/lib/python2.7/dist-packages/pyvttbl-0.5.2.2-py2.7.egg/pyvttbl/base.py
c in anova(self, dv, sub, wfactors, bfactors, measure, transform, alpha)
   1973         aov=stats.Anova()
   1974         aov.run(self, dv, sub=sub, wfactors=wfactors, bfactors=bfactors,
-> 1975                 measure=measure, transform=transform, alpha=alpha)
   1976         return aov
   1977 

/usr/local/lib/python2.7/dist-packages/pyvttbl-0.5.2.2-py2.7.egg/pyvttbl/stats/_
anova.pyc in run(self, dataframe, dv, wfactors, bfactors, sub, measure, 
transform, alpha)
    643 
    644         # a list of all the factors
--> 645         factors=wfactors+bfactors
    646         self.dftrim=0.
    647 

TypeError: can only concatenate list (not "str") to list

Original issue reported on code.google.com by J.DavidG...@gmail.com on 6 Feb 2014 at 11:31

rogerlew commented 7 years ago

bfactors must also be a list: aov = df.anova('dat', bfactors=['AgeGroup',] wfactors=['withinORcross','modality'])