Skip to contents

Computes the inverse logit (standard logistic sigmoid) function, \(\mathrm{logit}^{-1}(x) = 1/(1 + e^{-x})\), the canonical mean function for binomial/logistic-family models throughout this package (mapping a linear predictor on the log-odds scale back to a probability). The result is clamped to \([\code{zero\_one\_logit\_clamp}, 1 - \code{zero\_one\_logit\_clamp}]\) before being returned, so an extreme x (e.g. from a poorly identified or diverging fit) cannot produce an exact 0 or 1 probability that would later cause a -Inf/ NaN when log-transformed downstream (e.g. in a log-likelihood).

Usage

inv_logit(x, zero_one_logit_clamp = .Machine$double.eps)

Arguments

x

Any real number (or vector), typically a fitted linear predictor \(\eta = x_i^\top\beta\) on the log-odds scale.

zero_one_logit_clamp

The clamping distance from the 0/1 boundaries applied to the result. Default .Machine$double.eps.

Value

The inverse-logit-transformed value(s), in (0, 1), the same length as x.

See also

logit for the forward transform.

Examples

inv_logit(0)
#> [1] 0.5