Skip to contents

Computes the logit (log-odds) function \(\mathrm{logit}(p) = \log\left(p / (1-p)\right)\), the canonical link function for binomial/logistic-family models throughout this package. p is first clamped to \([\code{zero\_one\_logit\_clamp}, 1 - \code{zero\_one\_logit\_clamp}]\) before transforming, so exact 0 or 1 inputs (which would otherwise map to \(-\infty\)/\(\infty\)) instead return a large but finite value; this is what lets proportion/fractional responses with mass exactly at the boundary be used as pseudo-continuous inputs to logit-scale machinery elsewhere in the package (e.g. fast_ols_cpp-backed logit-transform-then-OLS shortcuts) without producing non-finite values.

Usage

logit(p, zero_one_logit_clamp = .Machine$double.eps)

Arguments

p

The value(s) to transform, nominally in (0, 1) (values outside that range, or exactly 0/1, are clamped rather than rejected).

zero_one_logit_clamp

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

Value

The logit-transformed value(s) as a real number (or vector), the same length as p.

See also

inv_logit for the inverse transform.

Examples

logit(0.25)
#> [1] -1.098612