1
$\begingroup$

I'm running the following code:

X = dataset[['X1 transaction date', 'X2 house age', 'X3 distance to the nearest MRT station', 'X4 number of convenience stores', 'X5 latitude', 'X6 longitude', 'X7 distance to Xindian Ditsrict Office', 'X8 distance to Cardinal Tien Hospital', 'X9 distance to Shih Hsin University']]

y = dataset['Y house price of unit area']

model = sm.Logit(y, X).fit()
print(model.summary())

I'm using a CSV dataframe with information about 414 different residential properties in the Xindian District of Taiwan. My goal is to use a logistic regression to determine which attributes have the greatest effect on the properties' prices.

When running my Logistic Regression, I get an Endog Error, as follows:

ValueError Traceback (most recent call last) in () 2 y = dataset['Y house price of unit area'] 3 ----> 4 model = sm.Logit(y, X).fit() 5 print(model.summary())

//anaconda/lib/python3.6/site-packages/statsmodels/discrete/discrete_model.py in init(self, endog, exog, **kwargs) 402 if (self.class.name != 'MNLogit' and 403 not np.all((self.endog>= 0) & (self.endog <= 1))): --> 404 raise ValueError("endog must be in the unit interval.") 405 406

ValueError: endog must be in the unit interval.

Does anyone know why I am getting an endog error, and how to correct this issue? My outcome variable is a continuous integer.

Thank you.

$\endgroup$
1
  • 1
    $\begingroup$ I guess you $y$ variable (house price) is not in (0,1) but it is continuous? In this case you cannot use logistic regression. This would be a regression problem. $\endgroup$ – Peter Dec 13 '19 at 11:51
1
$\begingroup$

The error comes from attempting to fit a classifier (logistic regression) on a regression problem. If you are trying to predict prices (continuous outcome), you should use linear regression.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.