| logit {poputils} | R Documentation |
Logit and Inverse-Logit Functions
Description
Transform values to and from the logit scale.
logit() calculates
Usage
logit(p)
invlogit(x)
Arguments
p |
Values in the interval |
x |
Values in the interval |
Details
x = \log \left(\frac{p}{1 - p}\right)
and invlogit() calculates
p = \frac{e^x}{1 + e^x}
To avoid overflow, invlogit()
uses p = \frac{1}{1 + e^{-x}}
internally for x where x > 0.
In some of the demographic literature, the logit function is defined as
x = \frac{1}{2} \log \left(\frac{p}{1 - p}\right).
logit() and invlogit() follow the conventions
in statistics and machine learning, and omit the
\frac{1}{2}.
Value
A vector of doubles, if
porxis a vector.A matrix of doubles, if
porxis a matrix.An object of class
rvec_dbl, ifporxis an rvec.
Examples
p <- c(0.5, 1, 0.2)
logit(p)
invlogit(logit(p))