# Ordinal regression

In statistics, ordinal regression, also called ordinal classification, is a type of regression analysis used for predicting an ordinal variable, i.e. a variable whose value exists on an arbitrary scale where only the relative ordering between different values is significant. It can be considered an intermediate problem between regression and classification. Examples of ordinal regression are ordered logit and ordered probit. Ordinal regression turns up often in the social sciences, for example in the modeling of human levels of preference (on a scale from, say, 1–5 for "very poor" through "excellent"), as well as in information retrieval. In machine learning, ordinal regression may also be called ranking learning.

## Linear models for ordinal regression

Ordinal regression can be performed using a generalized linear model (GLM) that fits both a coefficient vector and a set of thresholds to a dataset. Suppose one has a set of observations, represented by length-p vectors x$_1$ through x$_n$, with associated responses y$_1$ through y$_n$, where each y$_i$ is an ordinal variable on a scale 1, ..., K. For simplicity, and without loss of generality, we assume y is a non-decreasing vector, that is, y$_i$ $\leq$ y$_{i+1}$. To this data, one fits a length-p coefficient vector w and a set of thresholds θ$_1$, ..., θ$_{K−1}$ with the property that θ$_1$ < θ$_2$ < ... < θ$_{K−1}$. This set of thresholds divides the real number line into K disjoint segments, corresponding to the K response levels.
The model can now be formulated as
    $\Pr(y\leq i\mid \mathbf {x} )=\sigma (\theta _{i}-\mathbf {w} \cdot \mathbf {x} )$
or, the cumulative probability of the response y being at most i is given by a function σ (the inverse link function) applied to a linear function of x. Several choices exist for σ; the logistic function
    $\sigma (\theta _{i}-\mathbf {w} \cdot \mathbf {x} )={\frac {1}{1+e^{-(\theta _{i}-\mathbf {w} \cdot \mathbf {x} )}}}$
gives the ordered logit model, while using the CDF of the standard normal distribution gives the ordered probit model. A third option is to use an exponential function
    $\sigma (\theta _{i}-\mathbf {w} \cdot \mathbf {x} )=1-\exp(-\exp(\theta _{i}-\mathbf {w} \cdot \mathbf {x} ))$
which gives the proportional hazards model.

### Latent variable model

The probit version of the above model can be justified by assuming the existence of a real-valued latent variable (unobserved quantity) y*, determined by
    $y^{*}=\mathbf {w} \cdot \mathbf {x} +\varepsilon$
where ε is normally distributed with zero mean and unit variance, conditioned on x. The response variable y results from an "incomplete measurement" of y*, where one only determines the interval into which y* falls:
    $y={\begin{cases}1&{\text{if}}~~y^{*}\leq \theta _{1},\\2&{\text{if}}~~\theta _{1}<y^{*}\leq \theta _{2},\\3&{\text{if}}~~\theta _{2}<y^{*}\leq \theta _{3}\\\vdots \\K&{\text{if}}~~\theta _{K-1}<y^{*}.\end{cases}}$
Defining θ$_0$ = -∞ and θ$_K$ = ∞, the above can be summarized as y = k if and only if θ$_{k−1}$ < y* ≤ θ$_k$.
From these assumptions, one can derive the conditional distribution of y as
    ${\begin{aligned}P(y=k\mid \mathbf {x} )&=P(\theta _{k-1}<y^{*}\leq \theta _{k}\mid \mathbf {x} )\\&=P(\theta _{k-1}<\mathbf {w} \cdot \mathbf {x} +\varepsilon \leq \theta _{k})\\&=\Phi (\theta _{k}-\mathbf {w} \cdot \mathbf {x} )-\Phi (\theta _{k-1}-\mathbf {w} \cdot \mathbf {x} )\end{aligned}}$
where Φ is the cumulative distribution function of the standard normal distribution, and takes on the role of the inverse link function σ. The log-likelihood of the model for a single training example x$_i$, y$_i$ can now be stated as
    $\log {\mathcal {L}}(\mathbf {w} ,\mathbf {\theta } \mid \mathbf {x} _{i},y_{i})=\sum _{k=1}^{K}[y_{i}=k]\log[\Phi (\theta _{k}-\mathbf {w} \cdot \mathbf {x} _{i})-\Phi (\theta _{k-1}-\mathbf {w} \cdot \mathbf {x} _{i})]$
(using the Iverson bracket [y$_i$ = k].) The log-likelihood of the ordered logit model is analogous, using the logistic function instead of Φ.

## Alternative models

In machine learning, alternatives to the latent-variable models of ordinal regression have been proposed. An early result was PRank, a variant of the perceptron algorithm that found multiple parallel hyperplanes separating the various ranks; its output is a weight vector w and a sorted vector of K−1 thresholds θ, as in the ordered logit/probit models. The prediction rule for this model is to output the smallest rank k such that wx < θ$_k$.
Other methods rely on the principle of large-margin learning that also underlies support vector machines.
Another approach is given by Rennie and Srebro, who, realizing that "even just evaluating the likelihood of a predictor is not straight-forward" in the ordered logit and ordered probit models, propose fitting ordinal regression models by adapting common loss functions from classification (such as the hinge loss and log loss) to the ordinal case.

## Software

ORCA (Ordinal Regression and Classification Algorithms) is an Octave/MATLAB framework including a wide set of ordinal regression methods.
R packages that provide ordinal regression methods include MASS and Ordinal.