Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

multilogitlink

Multi-logit Link Function


Description

Computes the multilogit transformation, including its inverse and the first two derivatives.

Usage

multilogitlink(theta, refLevel = "(Last)", M = NULL, whitespace = FALSE,
               bvalue = NULL, inverse = FALSE, deriv = 0, all.derivs = FALSE,
               short = TRUE, tag = FALSE)

Arguments

theta

Numeric or character. See below for further details.

refLevel, M, whitespace

See multinomial.

bvalue

See Links.

all.derivs

Logical. This is currently experimental only.

inverse, deriv, short, tag

Details at Links.

Details

The multilogitlink() link function is a generalization of the logitlink link to M levels/classes. It forms the basis of the multinomial logit model. It is sometimes called the multi-logit link or the multinomial logit link; some people use softmax too. When its inverse function is computed it returns values which are positive and add to unity.

Value

For multilogitlink with deriv = 0, the multilogit of theta, i.e., log(theta[, j]/theta[, M+1]) when inverse = FALSE, and if inverse = TRUE then exp(theta[, j])/(1+rowSums(exp(theta))).

For deriv = 1, then the function returns d eta / d theta as a function of theta if inverse = FALSE, else if inverse = TRUE then it returns the reciprocal.

Here, all logarithms are natural logarithms, i.e., to base e.

Note

Numerical instability may occur when theta is close to 1 or 0 (for multilogitlink). One way of overcoming this is to use, e.g., bvalue. Currently care.exp() is used to avoid NAs being returned if the probability is too close to 1.

Author(s)

Thomas W. Yee

References

McCullagh, P. and Nelder, J. A. (1989). Generalized Linear Models, 2nd ed. London: Chapman & Hall.

See Also

Examples

pneumo <- transform(pneumo, let = log(exposure.time))
fit <- vglm(cbind(normal, mild, severe) ~ let,
            multinomial, trace = TRUE, data = pneumo)  # For illustration only!
fitted(fit)
predict(fit)

multilogitlink(fitted(fit))
multilogitlink(fitted(fit)) - predict(fit)  # Should be all 0s

multilogitlink(predict(fit), inverse = TRUE)  # rowSums() add to unity
multilogitlink(predict(fit), inverse = TRUE, refLevel = 1)  # For illustration only
multilogitlink(predict(fit), inverse = TRUE) - fitted(fit)  # Should be all 0s

multilogitlink(fitted(fit), deriv = 1)
multilogitlink(fitted(fit), deriv = 2)

VGAM

Vector Generalized Linear and Additive Models

v1.1-5
GPL-3
Authors
Thomas Yee [aut, cre], Cleve Moler [ctb] (author of several LINPACK routines)
Initial release
2021-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.