Flodude
Flodude

Reputation: 275

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'

Upvotes: 1

Views: 252

Answers (2)

David Ws.
David Ws.

Reputation: 144

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

Upvotes: 2

Szymon Kowaliński
Szymon Kowaliński

Reputation: 582

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

Upvotes: 0

Related Questions