1

I have a dataframe like so:

CRP    WEI   Kfact   CPI
0      1.2   4.5     2.3
0      0.5   5.0     0.2
0      1.1   1.4     3.2
1      3.8   6.7     9.2
1      2.3   5.6     9.5
1      1.3   3.4     8.3

and I want to run a logit model using statsmodel using CRP as the endogenous variable (dependent). I am using this code:

import pandas as pd
import statsmodels.api as sm

df=pd.read_csv(C:\path)

feature_cols=[col for col in df.columns if ('CRP' not in col)]
X=df[feature_cols].values
y=df['CRP'].values

X=sm.add_constant(X.exog, prepend=False)
y=y.endog

log_res = sm.Logit(y, X).fit()

print log_res.summary()

but this returns:

File "H:/Stefano/python codes/location_assessment/logit_model.py", line 23, in <module>
    X=sm.add_constant(X.exog, prepend=False)

AttributeError: 'numpy.ndarray' object has no attribute 'exog'
Stefano Potter
  • 3,467
  • 10
  • 45
  • 82

0 Answers0