1 year ago
#379734
Richard Nixon
How to change the reference category of the dependent variable in statsmodels when using Multi-nominal Regression?
I am trying to alter the reference category of the dependent variable (what party somebody voted for) while using statsmodels. I know that using C(socialclass, Treatment(reference=2)) allows me to change the reference category of one of the independent variables, social class in this example but this does not work for the dependent variable.
logitmodel = smf.mnlogit('C(ELECTIONVOTEALL, Treatment(reference=1)) ~ PMMAY + EUvotedremain +votedyes +C(socialclass, Treatment(reference=2))+ leftRight' , df)
dflogit_fit = logitmodel.fit()
I tried to do what had worked for the independent variable to the dependent variable however this produces an error which states the following:
ValueError: endog has evaluated to an array with multiple columns that has shape (2038, 4). This occurs when the variable converted to endog is non-numeric (e.g., bool or str).
Does anybody know how I can change the reference category of the dependent variable using statsmodels?
python
logistic-regression
statsmodels
multinomial
0 Answers
Your Answer