Python multinomial logit with statsmodels module: Change base value of mlogit regression

一个人想着一个人 提交于 2019-12-06 09:17:32

问题


I have a little problem which I am stuck with. I am building a multinomial logit model with Python statsmodels and wish to reproduce an example given in a textbook. So far so good, but I am struggling with setting a different target value as the base value for the regression. Can somebody help?!

import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt

#import data
df = pd.read_excel('C:/.../diabetes.xlsx')

#split the data in dependent and independent variables
y = df['CC']
X = df.drop(['Patient', 'CC'], axis = 1)
Xc = sm.add_constant(X)

#instantiate and fit multinomial logit
mlogit = sm.MNLogit(y, Xc)
fmlogit = mlogit.fit()

print(fmlogit.summary())

So the column 'CC' is the target variable and contains enconding for the diabetes status:

CC = 1 -> Overt diabetes, CC = 2 -> Chemical dibetes, CC = 3 -> Normal

Now, per default CC = 1 is the base value, however, I would like CC = 3 to be my base value. Here is my regression output.

Does anybody know?

Thanks a lot in advance, ig

来源:https://stackoverflow.com/questions/44096234/python-multinomial-logit-with-statsmodels-module-change-base-value-of-mlogit-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!