Learn R Programming

VGAM (version 0.9-1)

mlogit: Multinomial Logit Link Function

Description

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

Usage

mlogit(theta, refLevel = "last", M = NULL, whitespace = FALSE,
       bvalue = NULL, inverse = FALSE, deriv = 0,
       short = TRUE, tag = FALSE)

Arguments

theta
Numeric or character. See below for further details.
refLevel, M, whitespace
bvalue
See Links.
inverse, deriv, short, tag
Details at Links.

Value

  • For mlogit with deriv = 0, the mlogit 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 theta / d eta 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.

Details

The mlogit() link function is a generalization of the logit link to $M$ levels/classes. It forms the basis of the multinomial logit model.

References

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

See Also

Links, multinomial, logit.

Examples

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

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

mlogit(predict(fit), inverse = TRUE)
mlogit(predict(fit), inverse = TRUE, refLevel = 1) # For illustration only
mlogit(predict(fit), inverse = TRUE) - fitted(fit) # Should be all 0s

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

Run the code above in your browser using DataLab