Python multinomial logit with statsmodels module:

2019-04-15 21:55发布

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

0条回答
登录 后发表回答