This is an old version, view current version.

13.8 Ordered Logistic Generalized Linear Model (Ordinal Regression)

13.8.1 Probability Mass Function

If \(N,M,K \in \mathbb{N}\) with \(N, M > 0\), \(K > 2\), \(c \in \mathbb{R}^{K-1}\) such that \(c_k < c_{k+1}\) for \(k \in \{1,\ldots,K-2\}\), and \(x\in \mathbb{R}^{N\cdot M}, \beta\in \mathbb{R}^M\), then for \(y \in \{1,\ldots,K\}^N\), \[\text{OrderedLogisticGLM}(y~|~x,\beta,c) = \\[4pt] \prod_{1\leq i \leq N}\text{OrderedLogistic}(y_i~|~x_i\cdot \beta,c) = \\[17pt] \prod_{1\leq i \leq N}\left\{ \begin{array}{ll} 1 - \text{logit}^{-1}(x_i\cdot \beta - c_1) & \text{if } y = 1, \\[4pt] \text{logit}^{-1}(x_i\cdot \beta - c_{y-1}) - \text{logit}^{-1}(x_i\cdot \beta - c_{y}) & \text{if } 1 < y < K, \text{and} \\[4pt] \text{logit}^{-1}(x_i\cdot \beta - c_{K-1}) - 0 & \text{if } y = K. \end{array} \right. \] The \(k=K\) case is written with the redundant subtraction of zero to illustrate the parallelism of the cases; the \(y=1\) and \(y=K\) edge cases can be subsumed into the general definition by setting \(c_0 = -\infty\) and \(c_K = +\infty\) with \(\text{logit}^{-1}(-\infty) = 0\) and \(\text{logit}^{-1}(\infty) = 1\).

13.8.2 Sampling Statement

y ~ ordered_logistic_glm(x, beta, c)

Increment target log probability density with ordered_logistic_lpmf(y | x, beta, c) dropping constant additive terms.

13.8.3 Stan Functions

real ordered_logistic_glm_lpmf(int y | row_vector x, vector beta, vector c)
The log ordered logistic probability mass of y, given linear predictors x * beta, and cutpoints c.  The size of the independent variable row vector x needs to match the size of the coefficient vector beta. The cutpoints c must be ordered.

real ordered_logistic_glm_lpmf(int y | matrix x, vector beta, vector c)
The log ordered logistic probability mass of y, given linear predictors x * beta, and cutpoints c.  The same value of the independent variable y is used for all instances. The number of columns of the independent variable row vector x needs to match the size of the coefficient vector beta. The cutpoints c must be ordered. If x and y are data (not parameters) this function can be executed on a GPU.

real ordered_logistic_glm_lpmf(int[] y | row_vector x, vector beta, vector c)
The log ordered logistic probability mass of y, given linear predictors x * beta, and cutpoints c.  The same row vector of the independent variables x is used for all instances. The size of the independent variable row vector x needs to match the size of the coefficient vector beta. The cutpoints c must be ordered.

real ordered_logistic_glm_lpmf(int[] y | matrix x, vector beta, vector c)
The log ordered logistic probability mass of y, given linear predictors x * beta, and cutpoints c.  The number of rows of the independent variable matrix x needs to match the size of the dependent variable vector y. The number of columns of the independent variable row vector x needs to match the size of the coefficient vector beta. The cutpoints c must be ordered. If x and y are data (not parameters) this function can be executed on a GPU.