logloglink.RdComputes the two transformations, including their inverse and the first two derivatives.
logloglink(theta, bvalue = NULL, inverse = FALSE, deriv = 0,
short = TRUE, tag = FALSE)
loglogloglink(theta, bvalue = NULL, inverse = FALSE, deriv = 0,
short = TRUE, tag = FALSE)Numeric or character. See below for further details.
Values of theta which are less than or equal to
1 or \(e\)
can be
replaced by bvalue
before computing the link function value.
The component name bvalue stands for “boundary value”.
See Links for more information.
Details at Links.
The log-log link function is commonly used for parameters that
are greater than unity.
Similarly, the log-log-log link function is applicable
for parameters that
are greater than \(e\).
Numerical values of theta close to 1 or \(e\)
or out of range
result in
Inf, -Inf, NA or NaN.
One possible application of loglogloglink() is to
the \(k\) parameter (also called size)
of negbinomial to Poisson-like data but with
only a small amount of overdispersion; then \(k\) is
a large number relative to munb.
In such situations a loglink or
loglog link may not be sufficient to draw the
estimate toward the interior of the parameter space. Using a
more stronger link function can help mitigate the Hauck-Donner
effect hdeff.
For logloglink():
for deriv = 0, the log of log(theta), i.e.,
log(log(theta)) when inverse = FALSE,
and if inverse = TRUE then
exp(exp(theta)).
For loglogloglink():
for deriv = 0, the log of log(log(theta)), i.e.,
log(log(log(theta))) when inverse = FALSE,
and if inverse = TRUE then
exp(exp(exp(theta))).
For deriv = 1, then the function returns
d theta / d eta as a function
of theta
if inverse = FALSE,
else if inverse = TRUE then it returns the reciprocal.
Here, all logarithms are natural logarithms, i.e., to base e.
McCullagh, P. and Nelder, J. A. (1989). Generalized Linear Models, 2nd ed. London: Chapman & Hall.
Numerical instability may occur when theta is
close to 1 or \(e\)
unless bvalue is used.
x <- seq(0.8, 1.5, by = 0.1)
logloglink(x) # Has NAs
#> [1] NaN NaN -Inf -2.3506187 -1.7019834 -1.3380214 -1.0892396
#> [8] -0.9027205
logloglink(x, bvalue = 1.0 + .Machine$double.eps) # Has no NAs
#> [1] -36.0436534 -36.0436534 -36.0436534 -2.3506187 -1.7019834 -1.3380214
#> [7] -1.0892396 -0.9027205
x <- seq(1.01, 10, len = 100)
logloglink(x)
#> [1] -4.610149477 -2.342943351 -1.741196565 -1.391297954 -1.148325818
#> [6] -0.964431072 -0.817853393 -0.696875256 -0.594476773 -0.506129099
#> [11] -0.428746365 -0.360135528 -0.298685004 -0.243177735 -0.192673499
#> [16] -0.146431869 -0.103860074 -0.064476739 -0.027886026 0.006241174
#> [21] 0.038181203 0.068168147 0.096401880 0.123054303 0.148274228
#> [26] 0.172191262 0.194918903 0.216557058 0.237194077 0.256908438
#> [31] 0.275770131 0.293841816 0.311179785 0.327834784 0.343852697
#> [36] 0.359275137 0.374139947 0.388481631 0.402331731 0.415719141
#> [41] 0.428670396 0.441209912 0.453360203 0.465142065 0.476574746
#> [46] 0.487676093 0.498462677 0.508949912 0.519152159 0.529082815
#> [51] 0.538754394 0.548178608 0.557366423 0.566328126 0.575073377
#> [56] 0.583611258 0.591950315 0.600098601 0.608063711 0.615852816
#> [61] 0.623472691 0.630929747 0.638230052 0.645379356 0.652383114
#> [66] 0.659246501 0.665974436 0.672571593 0.679042420 0.685391151
#> [71] 0.691621822 0.697738278 0.703744191 0.709643063 0.715438242
#> [76] 0.721132927 0.726730178 0.732232923 0.737643967 0.742965997
#> [81] 0.748201587 0.753353207 0.758423229 0.763413928 0.768327490
#> [86] 0.773166015 0.777931524 0.782625959 0.787251191 0.791809018
#> [91] 0.796301176 0.800729334 0.805095103 0.809400036 0.813645631
#> [96] 0.817833334 0.821964542 0.826040602 0.830062817 0.834032445
max(abs(logloglink(logloglink(x), inverse = TRUE) - x)) # 0?
#> [1] 1.776357e-15