Learn R Programming

VGAMextra (version 0.0-6)

gammaRMlink: 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)

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

\(d\)theta1 / \(d\)

eta2 and

\(d\)theta2 / \(d\)

eta2

is returned.

Similarly, when deriv = 2, the second derivatives in terms of theta are returned.

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.

Author

V. Miranda and Thomas W. Yee.

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.

See Also

gammaRff, gammaR, Links.

Examples

Run this code
 
    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
   
 if (FALSE) {
 ## E2. Plot theta vs. eta, 'shape' fixed.
   plot(theta, eta, type = "l", las = 1, ylab = "", 
   main = "gammaRMlink(theta; shape)")
 }
 
 ## 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)
    

Run the code above in your browser using DataLab