Learn R Programming

VGAMextra (version 0.0-1)

gammaRMeanlink: Link functions for the mean of 2--parameter continuous distributions: The Gamma distribution.

Description

Computes the gammaRMeanlink transformation, its inverse and the first two derivatives.

Usage

gammaRMeanlink(theta, rate = NULL, wrt.param = NULL,
                       bvalue = NULL, inverse = FALSE,
                       deriv = 0, short = TRUE, tag = FALSE)

Arguments

theta

Numeric or character. This is \(\theta\) although may be \(\eta\) depending on the other parameters. See below for further details.

rate

A rate parameter. Same as gammaRMeanlink

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 Links.

Value

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

For deriv = 1, theta becomes \(\theta = (\alpha, \beta)=\)\((\theta1, \theta2)\), \(\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\). 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 \(\eta_1 = \log \frac{\alpha}{\beta}\), and \(\eta_2 = \log \beta\)

Details

This link function allows to model the mean of the 2--parameter gamma distribution.

The gammaRMeanlink transformation, for given \(\beta\), is defined as $$ \eta = \eta(\alpha; \beta) = \log \frac{\alpha}{\beta},$$ where \(\alpha > 0\) is a shape parameter, and \(\beta > 0\) is a rate parameter, as in gammaRMeanlink. Here, the gamma distribution is shape--rate parametrized, with mean \(\mu = \alpha / \beta\).

Note, this link is expressly a function of \(\alpha\), i.e. \(\theta\), therefore \(\beta\) must be passed down to the function at every call.

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

See Also

gammaRMean, gammaR, Links.

Examples

Run this code
# NOT RUN {
 
    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)
  
# }

Run the code above in your browser using DataLab