logit {LaplacesDemon} | R Documentation |
The logit and inverse-logit functions
Description
The logit and inverse-logit (also called the logistic function) are provided.
Usage
invlogit(x)
logit(p)
Arguments
x |
This object contains real values that will be transformed to the interval [0,1]. |
p |
This object contains of probabilities p in the interval [0,1] that will be transformed to the real line. |
Details
The logit
function is the inverse of the sigmoid or logistic
function, and transforms a continuous value (usually probability
) in the interval [0,1] to the real line (where it is usually
the logarithm of the odds). The
logit
function is .
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 ) in the interval
[0,1]. The
invlogit
function is .
If is a probability, then
is the
corresponding odds, while the
logit
of 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
in a logistic function (such as
invlogit
) is: .
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
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 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 .
Value
invlogit
returns probability p
, and
logit
returns x
.
See Also
interval
,
IterativeQuadrature
,
LaplaceApproximation
,
LaplacesDemon
,
plogis
,
PMC
,
qlogis
, and
VariationalBayes
.
Examples
library(LaplacesDemon)
x <- -5:5
p <- invlogit(x)
x <- logit(p)