Ordinal (ordered K-class) cumulative-logit regression via Laplace
Source:R/ordinal.R
tulpa_ordinal.RdFits 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.
Arguments
- formula
Model formula; the response must be an ordered (or coercible) factor with >= 3 levels, each observed at least once. An intercept in
formulais dropped;y ~ 1fits 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 SDsd(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_ordinalfit.- ...
Ignored.
- x
A
tulpa_ordinalfit.
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
# \donttest{
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
# }