Learn R Programming

VGAMextra (version 0.0-1)

inv.chisqMeanlink: Link functions for the mean of 1--parameter continuous distributions: The inverse chi--squared distribution.

Description

Computes the inv.chisqMeanlink transformation, its inverse and the first two derivatives.

Usage

inv.chisqMeanlink(theta, bvalue = NULL, inverse = FALSE,
                          deriv = 0, short = TRUE, tag = FALSE)

Arguments

theta

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

bvalue, inverse, deriv, short, tag

See Links.

Value

For deriv = 0, the inv.chisqMeanlink transformation of theta when inverse = FALSE. If inverse = TRUE, then the inverse exp(-theta) + 2.

For deriv = 1, \(d\) eta / \(d\) theta when inverse = FALSE. If inverse = TRUE, then \(d\) theta / \(d\) eta as a function of theta.

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

Details

This function arises as the link to model the mean of the inverse chi--squared distribution, inv.chisq.

It is defined as $$ \eta = -\log ( df - 2),$$ where \(df\) denotes the (non--negative) degrees of freedom, as in inv.chisq.

Notice, however, that \(df > 2\) is required for the mean of this distribution to be real. Consequently, the domain set for df for this link function is \((2, \infty)\).

Numerical values of \(df\) out of range will result in NA or NaN.

See Also

inv.chisq, Links.

Examples

Run this code
# NOT RUN {
 ##  E1. Modelling the mean of the exponential distribution  ##
    set.seed(17010502)
    dof <- 2.5 
    isq.data <- data.frame(x2 = runif(100, 0, 1))
    isq.data <- transform(isq.data, y = rinv.chisq(n = 100, df = dof + x2))
    
    
# }
# NOT RUN {
    hist(isq.data$y)
    
# }
# NOT RUN {
    
    fit.inv <- vglm(y ~ x2, family = inv.chisq(link = "inv.chisqMeanlink"), 
                    data = isq.data, trace = TRUE )
    coef(fit.inv, matrix = TRUE)
    summary(fit.inv)

  ## E3. Special values in a matrix ##
    (theta <- matrix(c(Inf, -Inf, NA, NaN, 1 , 2, 3, 4), ncol = 4, nrow = 2))
    inv.chisqMeanlink(theta = theta)   ## NaNs for df = theta <= 2 
 
  ## E2. inv.chisqMeanlink() and its inverse ##
    theta <- 0.1 + 1:5  # dof = df
    my.diff <- theta - inv.chisqMeanlink(inv.chisqMeanlink(theta = theta), inverse  =TRUE)
    summary(my.diff)     # Zero

# }

Run the code above in your browser using DataLab