Logit.Rd
Compute generalized logit and generalized inverse logit functions.
Logit(x, min = 0, max = 1)
LogitInv(x, min = 0, max = 1)
The generalized logit function takes values on [min, max] and
transforms them to span \([-\infty, \infty ]\).
It is defined as:
$$y = log\left (\frac{p}{1-p} \right ) \;\;\; \; \textup{where} \; \;\; p=\frac{x-min}{max-min}$$
The generalized inverse logit function provides the inverse transformation:
$$x = p' \cdot (max-min) + min \;\;\; \; \textup{where} \; \;\; p'=\frac{exp(y)}{1+exp(y)}$$
Transformed value(s).
logit
x <- seq(0,10, by=0.25)
xt <- Logit(x, min=0, max=10)
cbind(x,xt)
#> x xt
#> [1,] 0.00 -Inf
#> [2,] 0.25 -3.6635616
#> [3,] 0.50 -2.9444390
#> [4,] 0.75 -2.5123056
#> [5,] 1.00 -2.1972246
#> [6,] 1.25 -1.9459101
#> [7,] 1.50 -1.7346011
#> [8,] 1.75 -1.5505974
#> [9,] 2.00 -1.3862944
#> [10,] 2.25 -1.2367626
#> [11,] 2.50 -1.0986123
#> [12,] 2.75 -0.9694006
#> [13,] 3.00 -0.8472979
#> [14,] 3.25 -0.7308875
#> [15,] 3.50 -0.6190392
#> [16,] 3.75 -0.5108256
#> [17,] 4.00 -0.4054651
#> [18,] 4.25 -0.3022809
#> [19,] 4.50 -0.2006707
#> [20,] 4.75 -0.1000835
#> [21,] 5.00 0.0000000
#> [22,] 5.25 0.1000835
#> [23,] 5.50 0.2006707
#> [24,] 5.75 0.3022809
#> [25,] 6.00 0.4054651
#> [26,] 6.25 0.5108256
#> [27,] 6.50 0.6190392
#> [28,] 6.75 0.7308875
#> [29,] 7.00 0.8472979
#> [30,] 7.25 0.9694006
#> [31,] 7.50 1.0986123
#> [32,] 7.75 1.2367626
#> [33,] 8.00 1.3862944
#> [34,] 8.25 1.5505974
#> [35,] 8.50 1.7346011
#> [36,] 8.75 1.9459101
#> [37,] 9.00 2.1972246
#> [38,] 9.25 2.5123056
#> [39,] 9.50 2.9444390
#> [40,] 9.75 3.6635616
#> [41,] 10.00 Inf
y <- LogitInv(xt, min=0, max=10)
cbind(x, xt, y)
#> x xt y
#> [1,] 0.00 -Inf 0.00
#> [2,] 0.25 -3.6635616 0.25
#> [3,] 0.50 -2.9444390 0.50
#> [4,] 0.75 -2.5123056 0.75
#> [5,] 1.00 -2.1972246 1.00
#> [6,] 1.25 -1.9459101 1.25
#> [7,] 1.50 -1.7346011 1.50
#> [8,] 1.75 -1.5505974 1.75
#> [9,] 2.00 -1.3862944 2.00
#> [10,] 2.25 -1.2367626 2.25
#> [11,] 2.50 -1.0986123 2.50
#> [12,] 2.75 -0.9694006 2.75
#> [13,] 3.00 -0.8472979 3.00
#> [14,] 3.25 -0.7308875 3.25
#> [15,] 3.50 -0.6190392 3.50
#> [16,] 3.75 -0.5108256 3.75
#> [17,] 4.00 -0.4054651 4.00
#> [18,] 4.25 -0.3022809 4.25
#> [19,] 4.50 -0.2006707 4.50
#> [20,] 4.75 -0.1000835 4.75
#> [21,] 5.00 0.0000000 5.00
#> [22,] 5.25 0.1000835 5.25
#> [23,] 5.50 0.2006707 5.50
#> [24,] 5.75 0.3022809 5.75
#> [25,] 6.00 0.4054651 6.00
#> [26,] 6.25 0.5108256 6.25
#> [27,] 6.50 0.6190392 6.50
#> [28,] 6.75 0.7308875 6.75
#> [29,] 7.00 0.8472979 7.00
#> [30,] 7.25 0.9694006 7.25
#> [31,] 7.50 1.0986123 7.50
#> [32,] 7.75 1.2367626 7.75
#> [33,] 8.00 1.3862944 8.00
#> [34,] 8.25 1.5505974 8.25
#> [35,] 8.50 1.7346011 8.50
#> [36,] 8.75 1.9459101 8.75
#> [37,] 9.00 2.1972246 9.00
#> [38,] 9.25 2.5123056 9.25
#> [39,] 9.50 2.9444390 9.50
#> [40,] 9.75 3.6635616 9.75
#> [41,] 10.00 Inf 10.00