Learn R Programming

statisfactory (version 1.0.4)

logitAdj: A logit() function robust to values that equal 0 or 1

Description

This function returns the logit value (log(x / (1 - x))) where a small value can be added to x to avoid problems of calculating the log when x equals 0 or 1.

Usage

logitAdj(x, epsilon = 0.01, base = 10)

Value

Numeric equal to log((x + epsilon)/(1 - x + epsilon), base=base).

Arguments

x

Numeric vector.

epsilon

Value to add/subtract from x to ensure log of 0 or 1 is not taken (usually a small number). If NULL, then the smallest value of any x > 0 and 1 - x for all x < 1 is used.

base

Base of logarithm.

See Also

invLogitAdj

Examples

Run this code

set.seed(123)
x <- seq(0, 1, by=0.01)
logitAdj(x)
logitAdj(x, 0.001)
invLogitAdj(x, 0.001)
invLogitAdj(x, 0.001)
invLogitAdj(x, auto = TRUE)

Run the code above in your browser using DataLab