Logit multi-component / conditional regression, why does StatsModel not work on the example of the mlogit package?

I am trying to reproduce an example of polynomial logistic regression of the mlogit package in R.

data("Fishing", package = "mlogit")
Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode")
#a pure "conditional" model
summary(mlogit(mode ~ price + catch, data = Fish))

To reproduce this example using the statsmodel function of MNLogit, I export the Fishing dataset as a csv file and do the following

import pandas
import statsmodels.api as st
#load data
df = pandas.read_csv("Fishing.csv")
x = df.drop('mode', axis = 1)
y = df['mode']
mdl = st.MNLogit(y, x)
mdl_fit = mdl.fit()  

I get the following error

LinAlgError: Singular matrix

I tried to figure out how to reorganize the original Fishing dataset, since I know that the mlogit package will reorganize the data before installation, but cannot figure out how to change this in statsmodel. Any help would be greatly appreciated.

+4
source share
1 answer

MNLogit statsmodels . AFAICS, nnet multinom R https://stats.stackexchange.com/questions/186344/r-interpreting-the-multinom-output-using-the-iris-dataset/188426

, . CLogit mlogit R , .

CLogit logit statsmodels .

+1

Source: https://habr.com/ru/post/1622356/


All Articles