uninormalQlink: Quantile regression: Link function for the quantiles of the...

View source: R/uninormalQlink.R

uninormalQlinkR Documentation

Quantile regression: Link function for the quantiles of the normal distribution.

Description

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

Usage

     uninormalQlink(theta, percentile = stop("Enter percentiles."),
                    sd = NULL, wrt.param = NULL,
                    bvalue = NULL, inverse = FALSE,
                    deriv = 0, short = TRUE, tag = FALSE)
                       

Arguments

theta

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

percentile

Numeric. A vector of percentiles of interest, denoted as perc.

sd

Numeric, positive. The 'standard deviation' parameter (required), denoted as \sigma.

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

A 2-parameter link for the quantiles of the normal distribution. It can only be used within uninormalff as the first linear predictor. It is defined as

\tt{uninormalQlink}(\mu; \sigma) = \eta_1(\mu; \sigma) = \mu + \sigma \cdot \Phi^{-1}(perc),

where \Phi is the error function (see, e.g., erf), \mu in (-\infty, \infty), and \sigma > 0. This link is expressly a function of \theta = \mu, therefore sigma must be entered at every call. Numerical values of \sigma out of range may result in Inf, -Inf, NA or NaN.

Value

For deriv = 0, the uninormalQlink transformation of theta, i.e. \mu, when inverse = FALSE. If inverse = TRUE, then \theta becomes \eta, and the inverse, \eta - \sigma \Phi^{-1}(perc), for given \sigma, is returned.

When deriv = 1 theta becomes \theta = (\mu, \sigma)= (\theta_1, \theta_2), and \eta = (\eta_1, \eta_2) with \eta_2 = \log~\sigma, and the argument wrt.param must be considered:

A) If inverse = FALSE, then d eta1 / d \mu is returned when wrt.param = 1, and d eta1 / d \sigma if wrt.param = 2.

B) For inverse = TRUE, this link returns d \mu / d eta1 and d \sigma / d eta1 conformably arranged in a matrix, if wrt.param = 1, as a function of \theta_i, i = 1, 2. When wrt.param = 2, then d\mu / d eta2 and d\sigma / d eta2 is returned.

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

Note

Numerical instability may occur for values of sigma too close to zero. Use argument bvalue to replace the former only 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

uninormalff, uninormal, Links.

Examples

    eta <- seq(-3, 3, by = 0.1) # this is eta = log(Normal - Quantiles).
    sigma  <- exp(1)    # 'sigma' argument.
    percentile <- c(25, 50, 75, 95)  # some percentiles of interest.
 
 ## E1. Get 'mean' values.
   theta <- uninormalQlink(theta = eta, percentile = percentile,
                          sd = sigma, inverse = TRUE)  # Mu
   
 ## Not run: 
 ## E2. Plot theta vs. eta, 'shape' fixed, for different percentiles.
plot(theta[, 1], eta, type = "l", las = 1, lty = 2, lwd = 3,
     ylim = c(-10, 10), xlim = c(-10, 10),
     main = "uninormalQlink(theta; shape), fixed 'shape'.",
     xlab = "Theta (scale)", ylab = "uninormalQlink")
abline(v = 0, h = 0, col = "red")
lines(theta[, 2], eta, lty = 2, lwd = 3, col = "blue")
lines(theta[, 3], eta, lty = 2, lwd = 3, col = "orange")
lines(theta[, 4], eta, lty = 2, lwd = 3, col = "red")
legend("bottomright", c("25th Perc", "50th Perc", "75th Perc", "95th Perc"),
      col = c("black", "blue", "orange", "red"), lty = c(2, 2, 2, 2),
      lwd = rep(3, 4))

 
## End(Not run)
 
 ## E3. uninormalQlink() and its inverse ##
    etabis  <- uninormalQlink(theta = theta, percentile = percentile,
                              sd = sigma, inverse = FALSE)
    my.diff <- eta - etabis
    summary(my.diff)     # Zero

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