What to use to do multiple correlation?

血红的双手。 提交于 2019-12-03 07:17:16

You could certainly do this with statsmodels and pandas. Something like this might get you started

import pandas
import statsmodels.api as sm
from statsmodels.formula.api import ols

data = pandas.DataFrame([["A", 4, 0, 1, 27], 
                         ["B", 7, 1, 1, 29], 
                         ["C", 6, 1, 0, 23], 
                         ["D", 2, 0, 0, 20], 
                         ["etc.", 3, 0, 1, 21]], 
                         columns=["ID", "score", "male", "age20", "BMI"])
print data.corr()

model = ols("BMI ~ score + male + age20", data=data).fit()
print model.params
print model.summary()

Have a look at the documentation:

http://statsmodels.sourceforge.net/devel/

http://pandas.pydata.org/

Edit: I'm not familiar with the terminology multiple correlation coefficient, but I believe this is just square root of the R-squared of a multiple regression model no?

print model.rsquared**.5
print model.rsquared_adj**.5

Is this what you're after?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!