gammaRMlink {VGAMextra} | R Documentation |
Link functions for the mean of 2–parameter continuous distributions: The gamma distribution.
Description
Computes the gammaRMlink
transformation, its inverse and
the first two derivatives.
Usage
gammaRMlink(theta, shape = NULL, wrt.param = NULL,
bvalue = NULL, inverse = FALSE,
deriv = 0, short = TRUE, tag = FALSE)
Arguments
theta |
Numeric or character. This is |
shape |
The shape parameter. Same as
|
wrt.param |
Positive integer, either |
bvalue , inverse , deriv , short , tag |
See |
Details
The link to model the mean of the 2–parameter gamma distribution.
The gammaRMlink
transformation, for given
('shape' parameter),
is defined as
where is a rate parameter.
This link is expressly a function of
, i.e.
, therefore
(shape)
must be entered at every call.
Numerical values of or
out of range may
result in
Inf
, -Inf
, NA
or NaN
.
Value
For deriv = 0
, the gammaRMlink
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
, and
,
and then, the argument
wrt.param
must be
considered:
A) If inverse = FALSE
, then
eta1
/
theta1
when
wrt.param = 1
, and
eta1
/
theta2
if
wrt.param = 2
.
B) For inverse = TRUE
, this function returns
theta1
/
eta1
and
theta2
/
eta1
conformably arranged
in a matrix, if wrt.param = 1
,
as a function of ,
.
Also, when
wrt.param = 2
, a matrix with columns
theta1
/
eta2
and
theta2
/
eta2
is returned.
Similarly, when deriv = 2
, the second derivatives in
terms of theta
are returned.
Note
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.
Author(s)
V. Miranda and Thomas W. Yee.
See Also
Examples
eta <- seq(-3, 3, by = 0.1) # this is eta = log(mu(b, a)).
shape <- rep(exp(0.8), length(eta)) # 'shape' argument.
## E1. Get 'rate' values.
theta <- gammaRMlink(theta = eta, shape = shape, inverse = TRUE) # rate
## Not run:
## E2. Plot theta vs. eta, 'shape' fixed.
plot(theta, eta, type = "l", las = 1, ylab = "",
main = "gammaRMlink(theta; shape)")
## End(Not run)
## E3. gammaRMlink() and its inverse ##
etabis <- gammaRMlink(theta = theta, shape = shape, inverse = FALSE)
my.diff <- eta - etabis
summary(my.diff) # Zero
## E4. Special values arranged in a matrix ##
bbeta <- matrix(eta[1:9], ncol = 3, nrow = 3) #Ensure equal dimensions.
alpha <- matrix(c(Inf, -Inf, NA, NaN, -1 , 1, 0, -2, 2), ncol = 3, nrow = 3)
# The gammaRMlink transformation (log(a/b))
gammaRMlink(theta = bbeta, shape = alpha, inv = FALSE) # NaNs produced.
# Same as
log(alpha/bbeta)