tulpa_multinomial: Multinomial (nominal K-class) logistic regression via Laplace

View source: R/multinomial.R

tulpa_multinomialR Documentation

Multinomial (nominal K-class) logistic regression via Laplace

Description

Fits a baseline-category multinomial logit model: for a K-level unordered response, classes ⁠1..K-1⁠ each get their own linear predictor and class K is the baseline. The coupled multinomial likelihood is solved by a Newton step to the penalized mode (a Gaussian ridge prior on the coefficients) and summarized by a Laplace approximation, reusing the native multinomial kernel.

Usage

tulpa_multinomial(
  formula,
  data,
  beta_prior = .tulpa_default_beta_prior("multinomial"),
  control = list()
)

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

Arguments

formula

Model formula; the response must be a factor (or coercible to one) with >= 3 levels. The baseline is the last level.

data

A data frame.

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)). A finite SD keeps the mode finite under separation.

control

List of numerical knobs: max_iter (default 100), tol (default 1e-8), n_draws (posterior draws, default 2000), seed.

x

A tulpa_multinomial fit.

...

Ignored.

Value

A tulpa_fit (subclass tulpa_multinomial) with means (the posterior mode, named class:term) and cov of the Laplace Gaussian, which is the posterior coef(), vcov(), summary.tulpa_fit() and confint() report; draws sampled from that Gaussian; log_marginal, classes, baseline, and the standard generic-method support.

See Also

tulpa() for single-process GLMMs.

Examples


set.seed(1)
n <- 300L; x <- rnorm(n)
eta <- cbind(0.5 + 1.0 * x, -0.3 - 0.8 * x)          # classes 1, 2 vs baseline 3
P <- cbind(exp(eta), 1); P <- P / rowSums(P)
y <- factor(apply(P, 1, function(pr) sample.int(3L, 1L, prob = pr)))
fit <- tulpa_multinomial(y ~ x, data = data.frame(y = y, x = x))
coef(fit)


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