| tulpa_multinomial | R Documentation |
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.
tulpa_multinomial(
formula,
data,
beta_prior = .tulpa_default_beta_prior("multinomial"),
control = list()
)
## S3 method for class 'tulpa_multinomial'
print(x, ...)
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 |
control |
List of numerical knobs: |
x |
A |
... |
Ignored. |
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.
tulpa() for single-process GLMMs.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.