Chapter 12
Latent Variable Methods for Ordinal Data
Many measurements in the social and biomedical sciences are ordinal rather than truly metric: education level (no degree high school associate’s bachelor’s graduate), survey agreement scales ( to ), or binned income brackets. Treating “bachelor’s degree = 4” as twice “high school = 2” in a normal linear model imposes arbitrary arithmetic distances that do not exist in the data! Chapter 12 shows how latent Gaussian variables let us bring all of our multivariate normal and regression machinery to ordinal, skewed, and mixed discrete–continuous datasets without forcing any parametric assumption on the marginal scales.Peter D. Hoff. A First Course in Bayesian Statistical Methods. Springer Texts in Statistics. Springer, New York, 2009. ISBN 978-0-387-92299-7. doi: 10.1007/978-0-387-92407-6
12.1Ordered Probit Regression and Identifiability#
Consider Hoff’s 1994 General Social Survey example relating a respondent’s highest degree to their number of children and parent’s education indicator . An ordered probit regressionJames H. Albert and Siddhartha Chib. Bayesian Analysis of Binary and Polychotomous Response Data. Journal of the American Statistical Association, 88(422):669–679, 1993 posits an unobserved continuous latent score that follows a linear regression, together with ordered cutpoints mapping onto the observed ordinal categories:
(12.1)Hence (Figure 12.1, left panel).
Remark 12.1 (Why sigma^2 = 1 and the intercept is omitted). Notice two deliberate constraints in (12.1): there is no intercept in (with full-rank and its column space not containing the constant vector ), and the error variance is fixed at . Why? Because shifting every and every threshold by leaves every inequality unchanged (location non-identifiability), and multiplying both and by any likewise leaves every category probability unchanged (scale non-identifiability)! Fixing the intercept to and makes uniquely identifiable.
12.1.1Data-Augmentation Gibbs Sampler (Albert & Chib)#
Direct likelihood inference over involves awkward products of differences . Conditioning on the latent vector restores instant normality! Under and ordered normal priors on , the three full conditionals are:
Regression coefficients : standard Chapter 9 normal linear regression with known variance :
(12.2)Latent variables : independent truncated normal draws restricted to , sampled cleanly via the inverse-CDF method (Appendix B).
Thresholds : truncated normal on , where
(12.3)
Look closely at (12.3): when is large, the gap between and shrinks to ! That traps each threshold inside a microscopic corridor, causing excruciatingly slow MCMC mixing between , , and .
12.2Pettitt’s Rank Likelihood: Eliminating the Thresholds#
How do we eliminate the prior on and the tight – coupling—and even handle continuous non-normal responses where the number of distinct values is huge? Suppose for an unknown non-decreasing transformation . Even without knowing , observing tells us an exact order event on the latent vector :
(12.4)The rank likelihoodAnthony N. Pettitt. Inference for the Linear Model Using a Likelihood Based on Ranks. Journal of the Royal Statistical Society, Series B, 44(2):234–243, 1982 uses the probability of the event , bypassing (and all thresholds ) entirely:
(12.5)Because depends only on the ordering of and not on any numerical coding of categories or parametric form of , inference for is completely invariant to strictly increasing transformations of ! (Note that when is large and is small, each is still confined between neighboring categories, so convergence diagnostics remain essential.) Gibbs sampling under (12.5) requires only two blocks:
Algorithm 12.2 (Rank-Likelihood Regression Gibbs Sampler). Initialize (e.g., normal scores ) and . For :
Update from the normal regression conditional (12.2) given .
Update sequentially for : draw from truncated to the order-preserving interval , where
(with if is minimal, and if is maximal).
12.3Semiparametric Gaussian Copula Models#
Now elevate the exact same idea from regression to multivariate mixed data: suppose each respondent has a -dimensional vector mixing binary, ordinal, count, and skewed continuous variables (such as Hoff’s 1994 GSS dataset of 7 variables: INCOME, DEG, CHILD, PDEG, AGE, PINC, FEMALE).
By Sklar’s theoremAbe Sklar. Fonctions de répartition à dimensions et leurs marges. Publications de l’Institut de Statistique de l’Université de Paris, 8:229–231, 1959, any joint distribution with marginal CDFs can be decomposed into its marginals and a dependence function (a copula). The Gaussian copula models the dependence through a latent multivariate normal vector with unit variances and correlation matrix :
(12.6)where is the generalized inverse of the unknown marginal CDF (Figure 12.1, right panel).Subtlety of Sklar’s theorem for discrete margins: when all are continuous, the copula is unique. When some coordinates are discrete or ordinal, the copula is uniquely determined only on the Cartesian product of the ranges of ; the rank-likelihood posterior over integrates coherently over all latent orderings compatible with the observed ties, identifying the latent Gaussian correlation structure cleanly.Peter D. Hoff. Extending the Rank Likelihood for Semiparametric Copula Estimation. The Annals of Applied Statistics, 1(1):265–283, 2007
12.3.1Extended Rank Likelihood and Parameter Expansion#
Applying the rank likelihood column by column defines the order constraint , where within every column , . Look at what happens automatically when an entry is **missing at random (MAR)**Roderick J. A. Little and Donald B. Rubin. Statistical Analysis with Missing Data. John Wiley & Sons, Hoboken, NJ, second edition, 2002: it imposes no ordering constraint on , so —meaning we simply draw from its unconstrained conditional normal distribution given ! Missing data require literally zero extra machinery!
One obstacle remains: sampling a correlation matrix directly (subject to for all ) has no conjugate prior. HoffPeter D. Hoff. Extending the Rank Likelihood for Semiparametric Copula Estimation. The Annals of Applied Statistics, 1(1):265–283, 2007 resolves this with parameter expansionJun S. Liu and Ying Nian Wu. Parameter Expansion for Data Augmentation. Journal of the American Statistical Association, 94(448):1264–1274, 1999:
- Work with an unconstrained covariance matrix (for which is conjugate!) and treat —not —as the Markov chain state, placing on the prior induced through the correlation projection where .
- Why is this valid? Because rescaling column of by any positive standard deviation leaves the ordering event strictly invariant! Running the Gibbs sampler on the expanded pair with preserves the exact induced posterior of , which we simply record as output at every scan!
Algorithm 12.3 (Parameter-Expanded Gibbs Sampler for the Gaussian Copula). Initialize (column-wise normal scores, for missing entries) and . For :
- Update latent matrix given : for each column , compute the conditional regression weights and conditional variance from . For each observation , set :
- if is observed, draw from truncated to ;
- if is missing, draw unconstrained.
- Parameter-expanded covariance draw: draw and record the projected correlation matrix as output (keeping as the chain state for the next scan).Watch for a variable-naming typo in Hoff’s R code on p. 220, which defines the conditional regression-weight vector
Sz <- Sigma[j,-j] %*% solve(Sigma[-j,-j])on line 1 and then referencesSjcon lines 2–3; see Appendix C.
12.3.2Partial Regression and Latent Conditional Independence Graphs#
Once we have posterior draws from Algorithm 12.3, every tool from Chapter 7 carries over intact to arbitrary mixed ordinal data! In particular, computing the partial regression coefficients and the precision matrix at each iteration reveals the latent Gaussian graphical modelSteffen L. Lauritzen. Graphical Models. Oxford University Press, New York, 1996: a zero entry means and are conditionally independent given all remaining latent variables (note that this transfers directly to conditional independence of the observables and given only when all margins are continuous, since coarse discrete margins carry less conditioning information than the latent scores). In Hoff’s 1994 GSS analysis, marginal correlations link almost every pair of variables, whereas the partial coefficients isolate direct pathways—showing, for example, that respondent income depends strongly on DEG, AGE, and FEMALE, while parent’s education PDEG acts largely indirectly through the respondent’s own degree DEG!
import numpy as np
from scipy import stats
# Parameter-expanded Gaussian copula Gibbs sampler on mixed ordinal + skewed data
rng = np.random.default_rng(12)
n, p = 150, 3
C_true = np.array([[1.0, 0.65, 0.30], [0.65, 1.0, 0.50], [0.30, 0.50, 1.0]])
Z_true = rng.multivariate_normal(np.zeros(p), C_true, size=n)
# Create mixed non-normal observables: Y0 ordinal (1..5), Y1 skewed exp, Y2 binary (0/1)
Y = np.empty((n, p))
Y[:, 0] = np.digitize(stats.norm.cdf(Z_true[:, 0]), [0.15, 0.40, 0.70, 0.88]) + 1
Y[:, 1] = np.exp(0.7 * Z_true[:, 1])
Y[:, 2] = (Z_true[:, 2] > 0.2).astype(float)
Y[rng.uniform(size=(n, p)) < 0.08] = np.nan # inject 8% MCAR missing entries
# Initialize Z with column-wise normal scores (0 for missing) and Sigma = I_p
Z = np.zeros((n, p))
for j in range(p):
obs = ~np.isnan(Y[:, j])
ranks = stats.rankdata(Y[obs, j])
Z[obs, j] = stats.norm.ppf(ranks / (obs.sum() + 1.0))
nu0, S0 = p + 2.0, np.eye(p)
Sig = np.eye(p) # keep expanded Sigma as the Markov chain state!
S_iter = 600
C_draws = np.empty((S_iter, p, p))
for s in range(S_iter):
# 1. Update Z column by column given Sigma and order constraints R(Y)
for j in range(p):
oth = [k for k in range(p) if k != j]
w = np.linalg.solve(Sig[np.ix_(oth, oth)], Sig[oth, j])
sd = np.sqrt(max(Sig[j, j] - float(Sig[j, oth] @ w), 1e-8))
mu = Z[:, oth] @ w
yj = Y[:, j]
obs_vals = np.unique(yj[~np.isnan(yj)])
for val in obs_vals:
idx = np.where(yj == val)[0]
lo_mask = (~np.isnan(yj)) & (yj < val)
hi_mask = (~np.isnan(yj)) & (yj > val)
a = Z[lo_mask, j].max() if np.any(lo_mask) else -np.inf
b = Z[hi_mask, j].min() if np.any(hi_mask) else np.inf
ua = stats.norm.cdf((a - mu[idx]) / sd)
ub = stats.norm.cdf((b - mu[idx]) / sd)
u = rng.uniform(ua, np.maximum(ub, ua + 1e-12))
draw = mu[idx] + sd * stats.norm.ppf(np.clip(u, 1e-12, 1 - 1e-12))
Z[idx, j] = np.clip(draw, a, b)
mis = np.where(np.isnan(yj))[0]
if len(mis):
Z[mis, j] = rng.normal(mu[mis], sd)
# 2. Parameter-expanded Inverse-Wishart draw; record projected C = h(Sigma)
Sig = stats.invwishart.rvs(df=nu0 + n, scale=S0 + Z.T @ Z, random_state=rng)
d = np.sqrt(np.diag(Sig))
C_draws[s] = Sig / np.outer(d, d)
print("True C:\n", np.round(C_true, 2))
print("Posterior E[C | Y]:\n", np.round(C_draws[150:].mean(axis=0), 2))12.4Modern Developments: Copula Graphs, Exact Probit, and Efficiency#
12.4.1Gaussian Copula Graphical Models#
Section 12.3.2 read a latent graph off posterior draws of , but the inverse-Wishart draw of Algorithm 12.3 never yields an entry exactly equal to zero; a copula graphical model makes the graph itself a parameter.Beyond Hoff (2009). This material is not in Hoff’s book; Dobra and Lenkoski (2011) and Mohammadi et al. (2017) join Hoff’s extended rank likelihood to a prior on sparse precision matrices. Let be the expanded precision and the positive definite matrices with for every missing edge. The -Wishart prior givesAdrian Dobra and Alex Lenkoski. Copula Gaussian graphical models and their application to modeling functional disability data. The Annals of Applied Statistics, 5(2A):969–993, 2011. doi: 10.1214/10-AOAS397
(12.7)Why it holds. The normal likelihood multiplies the prior by , so simply updates, and the ratio of normalizers is the marginal likelihood of . For the complete graph and it is exactly Hoff’s Step 2. Parameter expansion survives because with : rescaling never creates or destroys a zero. The update is untouched. As is intractable for general graphs, and are explored jointly, by reversible jumpAdrian Dobra and Alex Lenkoski. Copula Gaussian graphical models and their application to modeling functional disability data. The Annals of Applied Statistics, 5(2A):969–993, 2011. doi: 10.1214/10-AOAS397 or by a birth–death process on edges.Abdolreza Mohammadi, Fentaw Abegaz, Edwin R. van den Heuvel, and Ernst C. Wit. Bayesian Modelling of Dupuytren Disease by Using Gaussian Copula Graphical Models. Journal of the Royal Statistical Society Series C: Applied Statistics, 66(3):629–645, 2017. doi: 10.1111/rssc.12171
When to use it. Use it when edge probabilities are the question or is large relative to . Keep Hoff’s inverse-Wishart when a few partial coefficients with intervals suffice. Edges describe the latent scores, with the caution of Section 12.3.2 for discrete margins.
12.4.2Exact i.i.d. Sampling for Binary Probit Regression#
With categories, the slow coupling behind (12.3) can be removed altogether: the posterior of is a known distribution, the unified skew-normal, and can be sampled without a Markov chain.Beyond Hoff (2009). This material is not in Hoff’s book; Durante (2019) proved this conjugacy, and Botev (2017) supplies the truncated-normal sampler that makes it practical, replacing Albert–Chib Gibbs. Code for , and let have rows so that the last entry of is the single threshold . With prior on the augmented vector, set and . ThenDaniele Durante. Conjugate Bayes for probit regression via unified skew-normal distributions. Biometrika, 106(4):765–779, 2019. doi: 10.1093/biomet/asz034
(12.8)where is the distribution function.
Why it holds. Let with . Given , is the probit likelihood, so conditioning on is conditioning on the data. As is jointly normal, regressing on gives both terms, and symmetry gives . Check: one observation with has , , and posterior mean . Truncated normals are drawn exactly by accept–reject with minimax exponential tilting.Z. I. Botev. The Normal Law Under Linear Restrictions: Simulation and Estimation via Minimax Tilting. Journal of the Royal Statistical Society Series B: Statistical Methodology, 79(1):125–148, 2017. doi: 10.1111/rssb.12162
When to use it. Use it for small to moderate , any (the cost sits in an -dimensional truncated normal), and for model comparison through , where only must be estimated. Keep the Gibbs sampler of Section 12.1.1 for large , or for with unknown thresholds.
12.4.3Efficiency of the Rank Likelihood and Margins under MAR#
The rank likelihood (12.5) and its copula extension discard everything but order, which raises two questions left open above: how much information is lost about , and how can we predict on the original scale without the margins ?Beyond Hoff (2009). This material is not in Hoff’s book; Hoff, Niu, and Wellner (2014) settle the first question for continuous margins, and Feldman and Kowal (2024) address the second for mixed and missing data. Let be a smoothly parameterized correlation matrix and the probability of the observed ranks. For continuous margins,Peter D. Hoff, Xiaoyue Niu, and Jon A. Wellner. Information bounds for Gaussian copulas. Bernoulli, 20(2):604–622, 2014. doi: 10.3150/12-BEJ499
(12.9)the second formula being evaluated at each draw of Algorithm 12.3, over observed and with value below the smallest of them.
Why it holds. The limit is that of the likelihood ratio in a suitably chosen multivariate normal model, so the information bound for rank-based estimators equals that for the full data, and the normal model is least favorable. For , , the information about a normal correlation with unknown variances: asymptotically, ignorance of the margins costs no more than ignorance of two variances. For the margins, is the event that lies below a latent cutpoint, which the largest latent score compatible with locates. Under missing at random the empirical distribution of the observed is biased in general, while this estimate inherits the correction made by the joint latent model. Feldman and Kowal use it with a mixture copula and prove posterior consistency for the margins and copula parameters under MAR and their regularity conditions;Joseph Feldman and Daniel R. Kowal. Nonparametric Copula Models for Multivariate, Mixed, and Missing Data. Journal of Machine Learning Research, 25(164):1–50, 2024 neither it nor Hoff’s algorithm is justified under MNAR, where missingness depends on the unseen value itself.
When to use it. For alone, use Hoff’s rank likelihood: with continuous margins the ranks forgo no first-order information (ties lie outside the theorem). Add the margins for imputation or prediction, and the mixture when dependence is visibly nonlinear.
12.4.4Computational & Symbolic Check#
For one observation with , the representation (12.8) reads , where given and . The script compares its exact i.i.d. draws with quadrature against the posterior, which is proportional to .Beyond Hoff (2009). This computational check and its Wolfram symbolic counterpart below verify the modern methods in this section and are not in Hoff’s book.
import math
import numpy as np
from scipy import integrate, stats
# 1. Quadrature: unnormalized posterior Phi(b) phi(b)
def moment(r):
f = lambda b: b ** r * stats.norm.cdf(b) * stats.norm.pdf(b)
return integrate.quad(f, -np.inf, np.inf)[0]
py = moment(0)
mean = moment(1) / py
print(f"p(y)={py:.6f}, mean={mean:.6f}, var={moment(2) / py - mean ** 2:.6f}")
print(f"exact: 0.5, {1 / math.sqrt(math.pi):.6f}, {1 - 1 / math.pi:.6f}")
# 2. Unified skew-normal: i.i.d. draws, no Markov chain
rng = np.random.default_rng(121)
T = math.sqrt(2.0) * np.abs(rng.normal(size=200_000)) # N(0,2) given T > 0
beta = 0.5 * T + math.sqrt(0.5) * rng.normal(size=T.size)
print(f"SUN draws: mean={beta.mean():.4f}, var={beta.var():.4f}")// Exact binary probit posterior, n = x = y = Sigma0 = 1: evidence and posterior mean
const pyInt = await show`Integrate[1/2*Erfc[-b/Sqrt[2]]*Exp[-b^2/2]/Sqrt[2*Pi], {b, -Infinity, Infinity}]`const numInt = await show`Integrate[b*1/2*Erfc[-b/Sqrt[2]]*Exp[-b^2/2]/Sqrt[2*Pi], {b, -Infinity, Infinity}]`const meanPost = await show`FullSimplify[(${numInt}) / (${pyInt})]`const meanSun = await show`FullSimplify[1/2*Integrate[t*Exp[-t^2/4]/Sqrt[4*Pi], {t, 0, Infinity}]
/ Integrate[Exp[-t^2/4]/Sqrt[4*Pi], {t, 0, Infinity}]]`await show`{FullSimplify[(${meanPost}) - (${meanSun})], N[${meanPost}], N[1 - (${meanPost})^2]}`12.5Symbolic Check in Wolfram Language#
Verifies ordered-probit shift/scale invariance symbolically in wolfram-ws-bridge JavaScript mode, derives both the precision entry and the symbolic partial correlation for a general Gaussian copula correlation matrix, solves , and contrasts exact conditional independence () against the Python simulation ().
// Chapter 12: Symbolic ordered-probit invariance & 3-variable Gaussian copula partial correlation
await show`Assuming[a > 0, Simplify[
1/2*Erfc[-((a*g + c) - (a*eta + c))/(a*Sqrt[2])] - 1/2*Erfc[-(g - eta)/Sqrt[2]]]]`// Latent precision Omega_{1,3}, partial correlation rho_{13|2}, and conditional-independence condition
const C3 = [[1, W.r12, W.r13], [W.r12, 1, W.r23], [W.r13, W.r23, 1]]
const Om = await show`Inverse[${C3}]`const omega13 = await show`Factor[${Om}[[1, 3]]]`const pcorr13 = await show`Assuming[-1 < r12 < 1 && -1 < r23 < 1,
FullSimplify[-${Om}[[1, 3]] / Sqrt[${Om}[[1, 1]] * ${Om}[[3, 3]]]]]`await show`r13 /. First[Solve[${omega13} == 0, r13]]`// Instantiate at (r12, r23) = (0.65, 0.50): r13 = 0.325 (exact CI) vs. Ch. 12 Python (r13 = 0.30)
await show`{${omega13} /. {r12 -> 13/20, r23 -> 1/2, r13 -> 13/40},
N[${omega13} /. {r12 -> 13/20, r23 -> 1/2, r13 -> 3/10}],
N[${pcorr13} /. {r12 -> 13/20, r23 -> 1/2, r13 -> 3/10}]}`12.6Exercises#
Exercise 12.4. Verify numerically using the Gaussian copula script above that replacing column with or leaves the posterior distribution of completely unchanged (up to Monte Carlo variation). Explain why this invariance fails for the standard multivariate normal model of Chapter 7.
Symbolic Solution & Instantiation
Integrate against to derive the exact Pearson correlation attenuation under .// Ex 12.1: Rank invariance vs. Pearson correlation distortion under nonlinear h(Z_1) = exp(sqrt(v)*Z_1)
const corrExp = await show`Assuming[v > 0, FullSimplify[
rho * Integrate[z*Exp[Sqrt[v]*z]*Exp[-z^2/2]/Sqrt[2*Pi], {z, -Infinity, Infinity}] /
Sqrt[Integrate[Exp[2*Sqrt[v]*z]*Exp[-z^2/2]/Sqrt[2*Pi], {z, -Infinity, Infinity}] - Exp[v]]]]`await show`N[${corrExp} /. {rho -> 1, v -> 1}]`Exercise 12.5. Simulate observations from an ordered probit model with categories and . Compare the lag-1 autocorrelation and effective sample size of under (a) the Albert–Chib threshold Gibbs sampler (12.3) and (b) the rank-likelihood Gibbs sampler Algorithm 12.2.
Symbolic Solution & Instantiation
Write the length-biased expected corridor width trapping an Albert–Chib threshold.// Ex 12.2: Length-biased threshold corridor width 2 / (n * phi(g)) trapping Albert-Chib thresholds (marginal Z ~ N(0,1))
const gapSym = await show`2 / (n * Exp[-g^2/2] / Sqrt[2*Pi])`await show`N[{${gapSym} /. {n -> 200, g -> 0}, ${gapSym} /. {n -> 200, g -> 1}}]`Exercise 12.6. In the copula script above, construct a 3-variable precision matrix with (so even though ). Run Algorithm 12.3, compute the posterior 95% credible intervals of and , and verify that the copula accurately distinguishes marginal correlation from conditional independence!
Symbolic Solution & Instantiation
Invert a tridiagonal precision matrix () to obtain the latent covariance .// Ex 12.3: Constructing a 3-variable Gaussian copula C from a tridiagonal precision Omega (Omega_{1,3} = 0)
const Om = [[W.a, W.Minus(W.b), 0], [W.Minus(W.b), W.a, W.Minus(W.b)], [0, W.Minus(W.b), W.a]]
const Sig = await show`Inverse[${Om}]`const c12 = await show`Assuming[a > 0 && b > 0 && a^2 > 2*b^2, FullSimplify[${Sig}[[1, 2]] / Sqrt[${Sig}[[1, 1]]*${Sig}[[2, 2]]]]]`const c13 = await show`Assuming[a > 0 && b > 0 && a^2 > 2*b^2, FullSimplify[${Sig}[[1, 3]] / Sqrt[${Sig}[[1, 1]]*${Sig}[[3, 3]]]]]`await show`N[{${c12}, ${c13}} /. {a -> 2, b -> 1}]`