简体   繁体   中英

Calculate a p-value in Python

I used the statsmodels.formula.api as below to calculate P-values. But apparently, this is not working in the new versions of the library. Do you know an alternative tool?

import statsmodels.formula.api as sm
# ...
regressor_OLS = sm.OLS(Y, x).fit()

Error:

AttributeError: module 'statsmodels.formula.api' has no attribute 'OLS'

Use statsmodels.api , instead of statsmodels.formula.api .

try changing
regressor_OLS = sm.OLS(Y, x).fit()
to
regressor_OLS = sm.OLS(endog=Y, exog=x).fit()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM