LogSt(x, calib = x, threshold = NULL, mult = 1)
LogStInv(x, threshold = NULL)
LogStInv
will
look for an attribute named "threshold"
if the argument is set to NULL
.Details
.attr(.,"threshold")
.
LogSt
handles this problem based on the following ideas:
These criteria are implemented here as follows: The shape is determined by a threshold $c$ at which - coming from above - the log function switches to a linear function with the same slope at this point.
This is obtained by
$$g(x) = \left\{\begin{array}{ll} log_{10}(x) &\textup{for }x \ge c\\ log_{10}(c) - \frac{c - x}{c \cdot log(10)} &\textup{for } x < c \end{array}\right. $$
Small values are determined by the threshold $c$. If not given by the argument threshold
, it is determined by the quartiles $q_1$ and $q_3$ of the non-zero data as those smaller than $c=q_1^{1+r}/q_3^r$ where $r$ can be set by the argument mult
.
The rationale is, that, for lognormal data, this constant identifies 2 percent of the data as small.
Beyond this limit, the transformation continues linear with the derivative of the log curve at this point.
Another idea for choosing the threshold $c$ was: median(x) / (median(x)/quantile(x, 0.25))^2.9) The function chooses $log_{10}$ rather than natural logs because they can be backtransformed relatively easily in the mind.
LogLin
dd <- c(seq(0,1,0.1), 5 * 10^rnorm(100, 0, 0.2))
dd <- sort(dd)
r.dl <- LogSt(dd)
plot(dd, r.dl, type="l")
abline(v=attr(r.dl, "threshold"), lty=2)
x <- rchisq(df=3, n=100)
# should give 0 (or at least something small):
LogStInv(LogSt(x)) - x
Run the code above in your browser using DataLab