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

logitAdjR Documentation

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)

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.

Value

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

See Also

invLogitAdj

Examples


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)


adamlilith/statisfactory documentation built on Jan. 3, 2024, 10:37 p.m.