tulpa_ordinal: Ordinal (ordered K-class) cumulative-logit regression via...

View source: R/ordinal.R

tulpa_ordinalR Documentation

Ordinal (ordered K-class) cumulative-logit regression via Laplace

Description

Fits a proportional-odds cumulative-logit model for an ordered factor response: ⁠P(y <= j | x) = plogis(c_j - x'beta)⁠ with ordered cutpoints ⁠c_1 < ... < c_{K-1}⁠. The penalized mode (a ridge prior on the coefficients and cutpoints) is found by L-BFGS and summarized by a Laplace approximation. There is no separate intercept – the cutpoints carry the baseline levels.

Usage

tulpa_ordinal(
  formula,
  data,
  link = c("logit", "probit"),
  beta_prior = .tulpa_default_beta_prior("ordinal"),
  cut_prior_sd = 10,
  control = list()
)

## S3 method for class 'tulpa_ordinal'
coef(object, ...)

## S3 method for class 'tulpa_ordinal'
print(x, ...)

Arguments

formula

Model formula; the response must be an ordered (or coercible) factor with >= 3 levels, each observed at least once. An intercept in formula is dropped; y ~ 1 fits the cutpoints alone. Incomplete rows are refused, not dropped.

data

A data frame.

link

Cumulative link: "logit" (proportional odds, default) or "probit".

beta_prior

Fixed-effect prior as list(mean, sd): a mean-zero (mean = 0) Gaussian ridge on every coefficient with scalar SD sd (default the engine default, prior_normal(0, 2.5)).

cut_prior_sd

SD of the mean-zero Gaussian ridge prior on the cutpoint parameters (default 10).

control

List of numerical knobs: max_iter (default 200), n_draws (default 2000), seed.

object

A tulpa_ordinal fit.

...

Ignored.

x

A tulpa_ordinal fit.

Value

A tulpa_fit (subclass tulpa_ordinal) with coefficients (covariate effects) and cutpoints at the posterior mode, draws (the Laplace Gaussian mapped to ordered cutpoints), log_marginal, levels. The draws are the posterior coef(), vcov(), summary.tulpa_fit() and confint() report; coef() omits the cutpoints, as MASS::polr does.

coef() returns the covariate effects without the cutpoints, as MASS::polr() omits its zeta; vcov() and summary() keep them.

See Also

tulpa_multinomial() for the nominal (unordered) case.

Examples


set.seed(1)
n <- 400L; x <- rnorm(n)
cuts <- c(-1, 0.5, 2); eta <- 0.8 * x
Fm <- plogis(outer(-eta, cuts, "+")); P <- cbind(Fm, 1) - cbind(0, Fm)
y <- ordered(apply(P, 1, function(pr) sample.int(4L, 1L, prob = pr)))
fit <- tulpa_ordinal(y ~ x, data = data.frame(y = y, x = x))
fit$coefficients; fit$cutpoints


tulpa documentation built on Oct. 19, 2026, 5:09 p.m.