logit: The logit and inverse-logit functions

Description Usage Arguments Details Value See Also Examples

View source: R/logit.R


The logit and inverse-logit (also called the logistic function) are provided.





This object contains real values that will be transformed to the interval [0,1].


This object contains of probabilities p in the interval [0,1] that will be transformed to the real line.


The logit function is the inverse of the sigmoid or logistic function, and transforms a continuous value (usually probability p) in the interval [0,1] to the real line (where it is usually the logarithm of the odds). The logit function is log(p / (1 - p)).

The invlogit function (called either the inverse logit or the logistic function) transforms a real number (usually the logarithm of the odds) to a value (usually probability p) in the interval [0,1]. The invlogit function is 1 / (1 + exp(-x)).

If p is a probability, then p/(1-p) is the corresponding odds, while the logit of p is the logarithm of the odds. The difference between the logits of two probabilities is the logarithm of the odds ratio. The derivative of probability p in a logistic function (such as invlogit) is: (d / dx) = p * (1 - p).

In the LaplacesDemon package, it is common to re-parameterize a model so that a parameter that should be in an interval can be updated from the real line by using the logit and invlogit functions, though the interval function provides an alternative. For example, consider a parameter theta that must be in the interval [0,1]. The algorithms in IterativeQuadrature, LaplaceApproximation, LaplacesDemon, PMC, and VariationalBayes are unaware of the desired interval, and may attempt theta outside of this interval. One solution is to have the algorithms update logit(theta) rather than theta. After logit(theta) is manipulated by the algorithm, it is transformed via invlogit(theta) in the model specification function, where theta in [0,1].


invlogit returns probability p, and logit returns x.

See Also

interval, IterativeQuadrature, LaplaceApproximation, LaplacesDemon, plogis, PMC, qlogis, and VariationalBayes.


x <- -5:5
p <- invlogit(x)
x <- logit(p)

LaplacesDemon documentation built on July 1, 2018, 9:02 a.m.