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")
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
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.
source
share