gammaRMeanlink {VGAMextra} | R Documentation |
Computes the gammaRMeanlink
transformation, its inverse and
the first two derivatives.
gammaRMeanlink(theta, rate = NULL, wrt.param = NULL, bvalue = NULL, inverse = FALSE, deriv = 0, short = TRUE, tag = FALSE)
theta |
Numeric or character. This is theta although may be η depending on the other parameters. See below for further details. |
rate |
A rate parameter. Same as
|
wrt.param |
Positive integer, either 1 or 2. The partial derivatives are computed with respect to one of the two linear predictors involved in this link. Further details listed below. |
bvalue, inverse, deriv, short, tag |
See |
This link function allows to model the mean of the 2–parameter gamma distribution.
The gammaRMeanlink
transformation, for given β,
is defined as
η = η(α; β) = log (α/β),
where α > 0 is a shape parameter, and β > 0
is a rate parameter, as in
gammaRMeanlink
.
Here, the gamma distribution is shape–rate parametrized, with
mean μ = α / β.
Note, this link is expressly a function of α, i.e. θ, therefore β must be passed down to the function at every call.
Numerical values of α out of range may
result in Inf
, -Inf
, NA
or NaN
.
For deriv = 0
, the gammaRMeanlink
transformation of
theta
, i.e. α, when inverse = FALSE
.
If inverse = TRUE
, then θ becomes η,
and the inverse,
exp(theta)
* β, for given β, is
returned.
For deriv = 1
, theta
becomes
θ = (α, β)=(θ1, θ2),
η = (η1, η2),
and then, the argument wrt.param
must be
considered:
A) If inverse = FALSE
, then
d eta1
/ d theta1
when
wrt.param = 1
, and
d eta1
/ d theta2
if
wrt.param = 2
.
B) For inverse = TRUE
, this function returns
d theta1
/ d eta1
and
d theta2
/ d eta1
conformably arranged
in a matrix, if wrt.param = 1
,
as a function of θi, i = 1, 2.
When wrt.param = 2
only
d theta1
/ d eta2
is returned,
since d theta2
/ d eta2
is
conviniently computed via the second link function.
See gammaRMeanlink
for
further details.
should return d theta
/ d eta2
which
is zero since
has no effect on the function since
Similarly, when deriv = 2
, the second derivatives in
terms of theta
are returned.
By default, the linear predictors in
gammaRMeanlink
are
η1 = log (α / β),
and η2 = log β
Numerical instability may occur for values theta
too close
to zero. Use argument bvalue
to replace them before
computing the link.
If theta
is character, then arguments inverse
and
deriv
are ignored. See Links
for further details.
V. Miranda and Thomas W. Yee.
alpha <- 0.1 + 1:8 # theta1 rate <- exp(1) # theta2 ## E1. gammaRMeanlink() and its inverse ## eta1 <- gammaRMeanlink(theta = alpha, rate = rate, inverse = FALSE) my.diff <- alpha - gammaRMeanlink(theta = eta1, rate = rate, inverse = TRUE) summary(my.diff) # Zero ## E2. Special values arranged in a matrix ## rate <- matrix(rate, ncol = 3, nrow = 3) #Ensure equal dimensions. alpha <- matrix(c(Inf, -Inf, NA, NaN, -1 , 1, 0, -2, 2), ncol = 3, nrow = 3) gammaRMeanlink(theta = alpha, rate = rate) # NaNs produced. ## E3. Special values arranged in a array ## dim(rate) <- NULL rate <- array(rate, dim = c(2, 2, 2)) #Ensure equal dimensions. alpha <- array(0.1 + 1:8, dim = c(2, 2, 2)) gammaRMeanlink(theta = alpha, rate = rate)