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. An intercept in
formulais 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.
Value
A tulpa_fit (subclass tulpa_ordinal) with coef (covariate
effects), cutpoints, vcov, draws, log_marginal, levels.
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
# }