I'm interested in running an ordered logit regression in python (using pandas, numpy, sklearn, or something that ecosystem). But I cannot find any way to do this. Is my google-skill lacking? Or is this not something that's been implemented in a standard package?
If you're looking for Ordered Logistic Regression, it looks like you can find it in Fabian Pedregosa's minirank
repo on GitHub.
(Hattip to @elyase, who originally provided the link in a comment on the question.)
Update: Logit and Probit Ordinal regression models are now built in to statsmodels.
https://www.statsmodels.org/devel/examples/notebooks/generated/ordinal_regression.html
from statsmodels.miscmodels.ordinal_model import OrderedModel
Examples are given in the documentation above. For 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)
mod_log = OrderedModel(data_student['apply'],
data_student[['pared', 'public', 'gpa']],
distr='logit')
res_log = mod_log.fit(method='bfgs', disp=False)
res_log.summary()
The catch is that the development version of statsmodels
is far ahead of the release. They say that installing the dev version of statsmodels
is okay for everyday use. So I used the following:
pip3 install [email protected]:statsmodels/statsmodels.git
to do so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With