Trying to get smf.mnlogit to work

24 views
Skip to first unread message

Brian Bull

unread,
Aug 1, 2025, 7:27:25 AMAug 1
to pystatsmodels
Hello group

I'm tearing my hair out trying to get smf.mnlogit to execute a simple multinomial regression.

With everything I try, including the following minimal example:

import pandas as pd

import statsmodels.formula.api as smf

data = pd.DataFrame({ 'choice': ['A', 'B', 'A', 'C', 'B', 'C', 'A', 'B', 'C', 'A'], 'feature1': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'feature2': [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] })

model = smf.mnlogit(formula='choice ~ feature1 + feature2', data=data).fit()


I get:
ValueError: endog has evaluated to an array that has multiple columns...

What am I doing wrong, please?
Or can you recommend a minimal example that does work??

Thanks
Brian

P.S. This is on statsmodels 0.14.5, pandas 2.3.1, Python 3.13
Reply all
Reply to author
Forward
0 new messages