statsmodel AttributeError: module 'scipy.stats' has no attribute 'chisqprob'
Asked Answered
S

3

16

I'm running the code below with statsmodel 0.8.0 which i believe is the latest.

import statsmodels.api as sm
est = sm.Logit(y_train, x_train)
result = est.fit()
print(result.summary())

This is giving me an error saying:

AttributeError: module 'scipy.stats' has no attribute 'chisqprob'.

I dont seem to be able to find anything on stackoverflow or elsewhere to resolve this. Any help much appreciated.

Supervisor answered 13/4, 2018 at 9:58 Comment(1)
See github.com/statsmodels/statsmodels/issues/3931Freemason
V
2

I had the same problem but this solved it. However, you first need to import stats from scipy.

stats.chisqprob = lambda chisq, df: stats.chi2.sf(chisq, df)

Hope it helps you.

Varner answered 25/4, 2018 at 11:7 Comment(0)
F
2

You have two options. Either use,

> result.summary2()

or you can import chisqprob.

> from scipy import stats

> stats.chisqprob = lambda chisq, df: stats.chi2.sf(chisq, df)
Fibrinous answered 23/2, 2021 at 6:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.