Virata manual

ologit

Explains an outcome with ordered categories — poor, fair, good, excellent.

What we have

  • cut points printed as Stata prints them, /cut1, /cut2 and so on
  • the sign convention and the cut points match R's MASS::polr (checked)

Coming later

  • a test of the proportional-odds assumption
  • predict and margins afterwards

How you write it

ologit depvar indepvars [if]

Square brackets mean optional. A vertical bar means choose one.

What it does

For categories that have an order but no meaningful spacing. "Good" is better than "fair", but it is not twice as good, so averaging the codes 1, 2, 3, 4 would be inventing arithmetic that is not there.

You get one coefficient per column — the effect of moving up the scale — and a set of thresholds (/cut1, /cut2, ...) marking where one category gives way to the next. It rests on the assumption that a column pushes you up every step of the ladder by the same amount (proportional odds).

Try it

Every example below was run after sysuse vira.sample03, clear.

. ologit rating age level
Ordered logistic regression                  Number of obs      =        4,000
                                             LR chi2            =        39.67
                                             Prob > chi2        =       0.0000
                                             Log likelihood     =   -5320.2780

------------------------------------------------------------------------------
      rating | Coefficient  Std. err.      z   P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
         age |    -.003733   .0037212   -1.00   0.316    -.0110264    .0035604
       level |    .1863775  .03072044    6.07   0.000     .1261665    .2465884
-------------+----------------------------------------------------------------
       /cut1 |   -3.077875
       /cut2 |   -.8344597
       /cut3 |    .9371662
       /cut4 |    3.075864
------------------------------------------------------------------------------
The same thing in pandas and in R

pandas

import pandas as pd

import patsy
from statsmodels.miscmodels.ordinal_model import OrderedModel
_, X = patsy.dmatrices('rating ~ age + level', df, return_type="dataframe")
X = X.drop(columns=["Intercept"], errors="ignore")
y = pd.Categorical(df['rating'], categories=sorted(df['rating'].dropna().unique()), ordered=True)
model = OrderedModel(y, X, distr="logit").fit(method="bfgs", disp=False)

R

library(MASS)
model <- polr(factor(rating) ~ age + level, data = df, Hess = TRUE,
    method = "logistic")
summary(model)

# This R was run in a real R (4.6.1) and gave the same numbers.

Nearby

regress logit probit poisson nbreg oprobit