Skip to contents

Reshapes an ordinal response y (levels \(1, \dots, K\)) into the stacked binary-outcome, per-cut-stratified form required to fit a (forward) continuation- ratio logit model as a single conditional (stratified) logistic regression — the discrete-time-hazard analog for ordinal data — so the package's existing binary/conditional-logit fitting backends can be reused unchanged rather than needing a bespoke ordinal solver. This is the continuation-ratio counterpart of expand_adjacent_category_data_cpp(); the two share the same stacking and combined-stratum trick but differ in which rows each subject contributes (see Details).

Usage

expand_continuation_ratio_data_cpp(y, w, strata, K)

Arguments

y

Integer vector of length \(n\): each subject's ordinal category label, in 1:K.

w

Integer vector of length \(n\): a covariate (typically treatment assignment) carried through unchanged into each stacked row for that subject.

strata

Integer vector of length \(n\): positive-integer stratum/block labels; max(strata) is used as the per-cut stratum-ID offset (see Details).

K

Integer; the number of ordinal categories (so there are K - 1 continuation-ratio cuts).

Value

A list with components y (stacked 0/1 "continued past this cut" outcome), w (stacked covariate, passed through unchanged), and strata (stacked combined stratum-by-cut ID); all three are integer vectors of the same, generally-longer-than-\(n\) length (each subject contributes between 1 and K - 1 stacked rows, depending on their observed category).

Details

Model. The continuation-ratio model treats reaching each successive category as a sequence of conditional "continue past this cut" events, analogous to a discrete-time survival/hazard model: for cut \(j = 1, \dots, K-1\), among subjects who have reached at least category \(j\) (\(Y \ge j\)), $$\log\frac{\Pr(Y > j \mid Y \ge j)}{\Pr(Y = j \mid Y \ge j)} = \alpha_j + \beta^\top x,$$ i.e. the log-odds of "continuing" past category \(j\) versus "stopping" (being observed) exactly there, given the subject has reached at least \(j\), with a cut-specific intercept \(\alpha_j\) and covariate effects \(\beta\) constrained equal across cuts (the proportional continuation-ratio assumption). This orientation — numerator is the "continue" event — keeps a positive \(\beta\) meaning "pushes toward higher categories of y", matching fast_continuation_ratio_regression_cpp and every other ordinal estimator in the package. Unlike the adjacent-category model (which only compares the two categories immediately flanking a cut), every subject contributes to every cut up to and including the one at which they are observed to stop.

Expansion mechanics. For each subject \(i\) with observed category y[i], a stacked row is emitted for every cut \(j = 1, \dots, \min(\code{y[i]}, K-1)\): the stacked binary outcome is 0 ("stopped here") if y[i] == j, and 1 ("continued past") for every earlier cut the subject passed through. A subject observed at the top category (y[i] == K) contributes a 1 at every one of the K - 1 cuts (having "survived" all of them without stopping); a subject observed at category j <= K - 1 contributes 1s for cuts 1:(j-1) and a single 0 at cut j, then no further rows (later cuts are irrelevant once a subject has already stopped). As in expand_adjacent_category_data_cpp(), the stacked stratum ID is strata[i] + (j - 1) * num_strata (with num_strata = max(strata)): fitting a conditional logistic regression stratified on this combined ID and pooling all stacked rows estimates a single shared treatment coefficient \(\beta\) across all cuts, while each (original stratum, cut) combination absorbs its own nuisance intercept via strata conditioning.

Input conventions. y must take integer values in 1:K; w is passed through unchanged into each stacked row for that subject (typically the treatment indicator/covariate to estimate a coefficient for); strata must be positive integers, with max(strata) used as the per-cut stratum-ID offset. No input validation is performed at this layer.

See also

expand_adjacent_category_data_cpp() for the analogous expansion used by adjacent-category ordinal models. Ordinal regression for orientation; analogous Python API: statsmodels discrete models (no direct continuation-ratio equivalent; the closest analog is fitting the expanded data as a conditional/grouped logit, or discrete-time survival packages).