View source: R/bound_transforms.R
logit | R Documentation |
Transform a between bound and unbounded scales.
logit(x, lower_bound = 0, upper_bound = 1, base = exp(1))
expit(x, lower_bound = 0, upper_bound = 1, base = exp(1))
x |
Value to be rescaled. |
lower_bound |
Lower bound of x; defaults to 0. |
upper_bound |
Upper bound of x; defaults to 1. |
base |
Base used for log-transform, defaults to |
logit()
will transform a value on a bound scale to an unbound scale,
while expit()
performs the reverse transformation. Values at the lower/upper
bounds correspond to -Inf
/Inf
on the unbounded scale. Uses the natural base,
e
, by default, but other bases can be passed to the parameter base
.
# unbound vector of values bound between [0, 1]
myvec <- seq(0, 10, 1)/10
logit(myvec)
# unbound vector of values between [100, 200]
myvec <- seq(100, 200, 10)
logit(myvec, lower_bound = 100, upper_bound = 200)
# bound vector of unbounded values to [0, 1]
myvec <- rnorm(10)
expit(myvec)
# bound vector of unbounded values to [100, 200]
expit(myvec, lower_bound = 100, upper_bound = 200)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.