Learn R Programming

VGAMextra (version 0.0-6)

weibullQlink: Weibull Quantile regression: Link function for the quantiles of the Weibull distribution.

Description

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

Usage

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

Value

For deriv = 0, the weibullQlink transformation of

theta, i.e. \(\beta\), when inverse = FALSE. If inverse = TRUE, then \(\theta\) becomes \(\eta\), and the inverse, exp[theta -

\((1 / \alpha) log(-log(1 - perc))\)],

for given

\(\alpha\), is returned.

When deriv = 1

theta becomes

\(\theta = (\beta, \alpha)= (\theta_1, \theta_2)\), and

\(\eta = (\eta_1, \eta_2)\) with

\(\eta_2 = \log~\alpha\), and the argument wrt.param must be considered:

A) If inverse = FALSE, then

\(d\)

eta1 / \(d\)

\(\beta\) is returned when

wrt.param = 1, and

\(d\)

eta1 / \(d\)

\(\alpha\) if

wrt.param = 2.

B) For inverse = TRUE, this link returns

\(d\)

\(\beta\) / \(d\)

eta1 and

\(d\)

\(\alpha\) / \(d\)

eta1 conformably arranged in a matrix, if wrt.param = 1, as a function of \(\theta_i\), \(i = 1, 2\). When wrt.param = 2, a matrix with columns

\(d\beta\) / \(d\)

eta2 and

\(d\alpha\) / \(d\)

eta2

is returned.

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

Arguments

theta

Numeric or character. Same as uninormalQlink

percentile

Same as uninormalQlink. Denoted below as perc.

shape

Numeric, positive. The shape parameter, required.

wrt.param

Same as in uninormalQlink

bvalue, inverse, deriv, short, tag

See Links.

Author

V. Miranda and Thomas W. Yee.

Details

The ordinary scale--shape Weibull quantiles are directly modelled by this link, aka weibullQlink transformation. It can only be used within weibullRff as the first linear predictor, \(\eta_1\), and is defined as $$ \tt{weibullQlink}(\beta; \alpha) = \eta_1(\beta; \alpha) = \log \{\beta \cdot [(-\log(1 - perc))^{(1/\alpha)}]\},$$ for given \(\alpha\) ('shape' parameter) where \(\beta > 0\) is the scale parameter. weibullQlink 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.

References

Miranda & Yee (2021) Two--Parameter Link Functions, With Application to Negative Binomial, Weibull and Quantile Regression. In preparation.

See Also

weibullRff, Q.reg, weibullR, weibmeanlink, Links.

Examples

Run this code
    eta <- seq(-3, 3, by = 0.1) # this is eta = log(Weibull-quantiles).
    shape  <- exp(1)    # 'shape' argument.
    percentile <- c(25, 50, 75, 95)  # some percentiles of interest.
 
 ## E1. Get 'scale' values. Gives a warning (not of the same length) !
   theta <- weibullQlink(theta = eta, percentile = percentile,
                         shape = shape, inverse = TRUE)  # Scale
   
 if (FALSE) {
 ## E2. Plot theta vs. eta, 'shape' fixed, for different percentiles.
plot(theta[, 1], eta, type = "l", lwd = 3,
     ylim = c(-4, 4), 
     main = paste0("weibullQlink(theta; shape = ", round(shape, 3), ")"), 
     xlab = "Theta (scale)", ylab = "weibullQlink")
abline(h = -3:3, v = 0, col = "gray", lty = "dashed")
lines(theta[, 2], eta, lwd = 3, col = "blue")
lines(theta[, 3], eta, lwd = 3, col = "orange")
lines(theta[, 4], eta, lwd = 3, col = "red")
legend("bottomright", c("25th Perc", "50th Perc", "75th Perc", "95th Perc"),
      col = c("black", "blue", "orange", "red"),
      lwd = rep(3, 4))
 }
 
 ## E3. weibullQlink() and its inverse ##
    etabis  <- weibullQlink(theta = theta, percentile = percentile,
                            shape = shape, inverse = FALSE)
    summary(eta - etabis)     # Should be 0 for each colum (percentile)

Run the code above in your browser using DataLab