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

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/uninormalQlink.R

Description

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

Usage

1
2
3
4
5
     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 η 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 σ.

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

uninormalQlink(μ; σ) = η_1(μ; σ) = μ + σ * Φ^(-1)(perc)

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

Value

For deriv = 0, the uninormalQlink transformation of theta, i.e. μ, when inverse = FALSE. If inverse = TRUE, then θ becomes η, and the inverse, η - σ Φ^{-1}(perc), for given σ, is returned.

When deriv = 1 theta becomes θ = (μ, σ)= (θ_1, θ_2), and η = (η_1, η_2) with η_2 = log σ, and the argument wrt.param must be considered:

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

B) For inverse = TRUE, this link returns d μ / d eta1 and d σ / d eta1 conformably arranged in a matrix, if wrt.param = 1, as a function of θi, i = 1, 2. When wrt.param = 2, then / d eta2 and / 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    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 May 24, 2021, 9:07 a.m.