mlogit: mlogit - Convert multiple probabilities to log-scale numbers

View source: R/mlogit.R

mlogitR Documentation

mlogit – Convert multiple probabilities to log-scale numbers

Description

These multiple probabilities need to add up to be less than 1.

Usage

mlogit(
  ...,
  maxiter = 10000,
  rtol = 1e-10,
  atol = 1e-12,
  ctol = 1e-12,
  returnRoot = FALSE
)

Arguments

...

numeric probabilities to convert to log-scale numbers. These probabilities must add to a number less than 1 and are used in the mix() estimation algorithm.

maxiter

maximal number of iterations allowed.

rtol

relative error tolerance, either a scalar or a vector, one value for each element in the unknown x.

atol

absolute error tolerance, either a scalar or a vector, one value for each element in x.

ctol

a scalar. If between two iterations, the maximal change in the variable values is less than this amount, then it is assumed that the root is found.

returnRoot

logical; If TRUE, return the root object, otherwise return the root itself.

Details

Once converted to log-scale numbers, they can be used in the in the mexpit() to get the probabilities back with the following equation

p_i = \frac{e^{x_i}}{1+\sum_{j=1}^{N-1} e^{x_j}}

This ensures one remaining probability will add to one, that is

p_N = \frac{1}{1+\sum_{j=1}^{N-1} e^{x_j}}

Unfortunately, the log-scale inverse cannot be solved analytically, so it is solved with the rootSolve::multiroot() function.

You may adjust some of the root finding options when using this function.

When running nlmixr2 with mixture models (ie. mix() models), the mlogit() function is called in the probabilities and the log-based values are used in the optimization problem. The probabilities are determined by the mexpit() function.

Value

A numeric vector of the log-scale numbers for use in regressions where the sum of a set of probabilities must add to be one.

Author(s)

Matthew L. Fidler

Examples


mlogit(0.1, 0.2, 0.3)

mlogit(0.1, 0.2, 0.3, returnRoot = TRUE)


rxode2 documentation built on July 28, 2026, 5:08 p.m.