Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coefficients differs from statsmodel when there is no regularization (alpha = 0) #26

Open
guilhermeparreira opened this issue Oct 31, 2022 · 1 comment

Comments

@guilhermeparreira
Copy link

Hi There!
I am enjoying using your package to analyse ordinal data. However, when I compared the results of mord.LogisticAT(alpha = 0) against from statsmodels.miscmodels.ordinal_model import OrderedModel I obtained different coefficients. Should not they be the same? (As long as I am not using any regularization technique?).

Here is a reproducible example:

import pandas as pd
from statsmodels.miscmodels.ordinal_model import OrderedModel

url = "https://stats.idre.ucla.edu/stat/data/ologit.dta"
data_student = pd.read_stata(url)
X, y = data_student[['pared', 'public', 'gpa']], data_student['apply'] 
mod_prob = OrderedModel(y,
                        X,
                        distr='logit')

res_prob = mod_prob.fit(method='bfgs')
res_prob.summary()

image

MORD:

import mord
from sklearn.preprocessing import LabelEncoder

le = LabelEncoder()
y = le.fit_transform(y)
model_mord = mord.LogisticAT(alpha = 50)
model_mord.fit(X, y)
y_pred = model_mord.predict(X)
print('\nCoef mord', model_mord.coef_)
Coef mord [-0.02192845  0.12534365  0.01633311]

which differ a lot from OrderedModel (coefficient of pared is 1.0476 in stasmodel and -0.02192845 in mord).

Also, could I exponentiate the model_mort.coef_ and interpret it as the traditional Odds_Ratio?

Thanks in advance!!

@varkmiti
Copy link

Hi, I have noticed the same issue recently. I am not sure if I am using an outdated version, but I would like to see this addressed. After extensive testing, it looks like Mord LogitsticAT agrees with MatLab's mnrfit (link here)––at least up to some floating point accuracy. I would be interested in working on a solution or at least a better understanding of the differences between mord, MatLab, and statsmodels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants