# Ordinal logistic regression in Python

I would like to run an ordinal logistic regression in Python - for a response variable with three levels and with a few explanatory factors. The statsmodels package supports binary logit and multinomial logit (MNLogit) models, but not ordered logit. Since the underlying math is not that different, I wonder if it can be implemented easily using these? (Alternatively, other Python packages that work are appreciated.)

• The only code in python that I know of is by Fabian see the statsmodels issue github.com/statsmodels/statsmodels/issues/807 . I think it wouldn't be difficult to implement for statsmodels, but nobody volunteered yet. Aug 23 '15 at 14:37
• This is not Python, but in R the orm function in the rms package efficiently handles thousands of levels of the response variable. Dec 30 '15 at 12:59
• In conjunction w/ @FrankHarrell's comment above, note that you can call R functions from Python w/ rpy2 (see also: A Slug's Guide to Python). Dec 30 '15 at 16:24
• This is arguably on-topic since the question doesn't seem to be a pure code request - whether one can cobble an ordered logit model out of the computational ingredients of binary logit and MNLogit seems to me to be a question with a statistical character (even if the ultimate solution turns out to be something like "no, use a different package") Dec 30 '15 at 16:57
• Indeed, I ended up using R modules through rpy2, as well as simplifying my model specification to binary logit.
Dec 31 '15 at 19:32

statsmodels now supports Ordinal Regression:
from statsmodels.miscmodels.ordinal_model import OrderedModel

• statsmodels now supports Ordinal Regression, but not in the released version. They say that installing the dev version of statsmodels is okay for everyday use. So I did: pip3 install git+git://github.com/someuser/someproject.git