Logit Transformation
logit.RdCompute the logit transformation of proportions or percentages.
Arguments
- p
numeric vector or array of proportions or percentages.
- percents
TRUEfor percentages,FALSEfor proportions. If the argument is missing and the largest value ofp> 1,percentsis set toTRUE, otherwise toFALSE.- adjust
adjustment factor to avoid proportions of 0 or 1; defaults to
0if there are no such proportions in the data, and to.025if there are.
Details
Computes the logit transformation logit \(=\log [p/(1-p)]\) for the proportion \(p\).
If \(p=0\) or \(1\), then the logit
is undefined. logit can remap the proportions to the interval
(adjust, 1 - adjust) prior to the transformation. If it adjusts the data
automatically, logit will print a warning message.
References
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
Author
John Fox jfox@mcmaster.ca and Iain Proctor
Examples
save.opt <- options(digits=4)
logit(.1*0:10)
#> Warning: proportions remapped to (0.025, 0.975)
#> [1] -3.6636 -1.9924 -1.2950 -0.8001 -0.3847 0.0000 0.3847 0.8001 1.2950
#> [10] 1.9924 3.6636
logit(.1*0:10, adjust=0)
#> [1] -Inf -2.1972 -1.3863 -0.8473 -0.4055 0.0000 0.4055 0.8473 1.3863
#> [10] 2.1972 Inf
logit(10*1:9, percents=TRUE)
#> [1] -2.1972 -1.3863 -0.8473 -0.4055 0.0000 0.4055 0.8473 1.3863 2.1972
options(save.opt)