Learn R Programming

jSDM (version 0.1.0)

logit: Generalized logit and inverse logit function

Description

Compute generalized logit and generalized inverse logit functions.

Usage

logit(x, min = 0, max = 1)
inv_logit(x, min = 0, max = 1)

Arguments

x

value(s) to be transformed

min

Lower end of logit interval

max

Upper end of logit interval

Value

Transformed value(s).

Details

The generalized logit function takes values on [min, max] and transforms them to span [-Inf,Inf] it is defined as:

$$y = log(\frac{p}{(1-p)})$$

where

$$p=\frac{(x-min)}{(max-min)}$$

The generalized inverse logit function provides the inverse transformation:

$$x = p' (max-min) + min$$

where

$$p'=\frac{exp(y)}{(1+exp(y))}$$

Examples

Run this code
# NOT RUN {
  x <- seq(0,10, by=0.25)
  xt <- jSDM::logit(x, min=0, max=10)
  cbind(x,xt)
  y <- jSDM::inv_logit(xt, min=0, max=10)
  cbind(x,xt,y)  
# }

Run the code above in your browser using DataLab