# gammaRMeanlink: Link functions for the mean of 2-parameter continuous... In VGAMextra: Additions and Extensions of the 'VGAM' Package

 gammaRMlink 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 \theta ('rate' parameter) but iy may be \eta depending on the other parameters. See below for further details. shape The shape parameter. Same as gammaRff. wrt.param Positive integer, either 1 or 2. The partial derivatives are computed with respect to one of the two linear predictors involved with this link. Further details listed below. bvalue, inverse, deriv, short, tag See Links.

### Details

The link to model the mean of the 2â€“parameter gamma distribution.

The gammaRMlink transformation, for given \alpha ('shape' parameter), is defined as

 \eta = \eta(\alpha; \beta) = \log \frac{\alpha}{\beta},

where \beta > 0 is a rate parameter. This link is expressly a function of \beta, i.e. \theta, therefore \alpha (shape) must be entered at every call.

Numerical values of \alpha or \beta out of range may result in Inf, -Inf, NA or NaN.

### Value

For deriv = 0, the gammaRMlink transformation of theta, i.e. \beta, when inverse = FALSE. If inverse = TRUE, then \theta becomes \eta, and the inverse, \alpha * exp(-theta), for given \alpha, is returned.

For deriv = 1, theta becomes \theta = (\beta, \alpha)=(\theta1, \theta2), and \eta = (\eta1, \eta2), 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 \theta_i, i = 1, 2. Also, when wrt.param = 2, a matrix with columns dtheta1 / d eta2 and dtheta2 / d 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

gammaRff, gammaR, Links.

### 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)



VGAMextra documentation built on Nov. 2, 2023, 5:59 p.m.