logit_utils | R Documentation |
Logit and inverse logit functions, with option to perform a transformation such that the domain in non-logit space is as specified (standard is (0, 1)).
logit(x, domain_lower = 0, domain_upper = 1)
invlogit(x, domain_lower = 0, domain_upper = 1)
check_logit_inputs(x, domain_lower, domain_upper)
x |
[ |
domain_lower |
[ |
domain_upper |
[ |
Standard:
logit (x) = log (x / (1-x))
inverse logit (x) = exp (x) / (1 + exp (x))
Optional logit with transformed domain:
logit (x, l, u) = log (x' / (1 - x')) where x' = (x - l) / (u - l)
inverse logit (x, l, u) = ( exp (x) / (1 + exp (x)) ) * (u - l) + l
Other notes: Values of x outside of (domain_lower
, domain_upper
)
will return NaN and result in a warning from logit
function.
[numeric()
]
The calculated logit or inverse logit value.
# Standard
logit(0.1)
invlogit(-2)
# Domain shift
x <- stats::runif(n = 100, min = 10, max = 20)
logit_x <- logit(x, domain_lower = 10, domain_upper = 20)
x_again <- invlogit(logit_x, domain_lower = 10, domain_upper = 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.