python - statsmodels examples seem not to work -


import statsmodels.formula.api sm import numpy np import pandas  url = "http://vincentarelbundock.github.com/rdatasets/csv/histdata/guerry.csv" df = pandas.read_csv(url) df = df[['lottery', 'literacy', 'wealth', 'region']].dropna() print df.head() mod = sm.ols(formula='lottery ~ literacy + wealth + region', data=df) res = mod.fit() print res.summary() 

spits error after printing table.

--------------------------------------------------------------------------- typeerror                                 traceback (most recent call last) <ipython-input-4-f69caff21ed0> in <module>() 6 df = df[['lottery', 'literacy', 'wealth', 'region']].dropna() 7 print df.head() ----> 8 mod = sm.ols(formula='lottery ~ literacy + wealth + region', data=df) 9 res = mod.fit() 10 print res.summary()  typeerror: from_formula() takes @ least 3 arguments (2 given) 

this not seem acceptable behavior. doing wrong?

(the guess in comment wrong)

your version of statsmodels old. documentation , example correct released version of statsmodels 0.5.

the data keyword has been renamed df since 0.5.0.dev-1bbd4ca.

so either upgrade, highly recommend, or use old keyword name

mod = sm.ols(formula='lottery ~ literacy + wealth + region', df=df) 

should work version have.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -