uninormalff: Normal (distribution-specified) quantile regression

View source: R/uninormalff.R

uninormalffR Documentation

Normal (distribution–specified) quantile regression

Description

Distribution–specified quantile regression. An extension of uninormal from VGAM. It handles effectively uninormalQlink via the first linear predictor.

Usage

    
     uninormalff(link1 = "identitylink", lsd = "loglink",
                 percentile = 50,
                 imethod = 1, isd = NULL, parallel = FALSE,
                 smallno = 1.0e-5, zero = "sd")
             

Arguments

link1

Link function for the first linear predictor. By default link1 = "identitylink", same as lmean from uninormal. Set link1 = "uninormalQlink" for normal quantile regression. See details below.

percentile

Numeric. A vector with the percentiles of interest, between 0 and 100. Used only when link1 = "uninormalQlink".

lsd, imethod, isd, parallel, smallno, zero

Same as in uninormal, except that "sd" is the only accepted value for zero.

Details

An extension of uninormal adapted to handle uninormalQlink, for normal quantile regression (QR) via the first linear predictor.

The standard deviation only can be estimated. The second linear predictor is fixed to \eta_2 = \log \sigma, and var.arg is set internally to FALSE.

Unlike usual QR where the distribution of Y|X is unspecified, uninormalff() estimates normal distributions at different quantiles (as entered in percentile) of the Y|X. For this, set link1 = uninormaQlink. To mimic uninormal set link1 = "identitylink" (default).

Initial developments of this work are in Miranda & Yee (2019). See, e.g., weibullRff, for another example on distribution specified quantile regression with the two–parameter Weibull distribution.

Value

An object of class "vglm". See vglm-class for full details.

Note

Q.reg must be used in the vglm() or vgam() to enter the response. See example below.

This VGAM family function does not handle censored data.

Author(s)

V. Miranda and Thomas W. Yee.

References

Miranda & Yee (2019) New Link Functions for Distribution–Specific Quantile Regression Based on Vector Generalized Linear and Additive Models. Journal of Probability and Statistics, Article ID 3493628.

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

See Also

uninormalQlink, uninormal, Q.reg, weibullQlink, weibullRff, CommonVGAMffArguments.

Examples

## Not run: 

x2 <- seq(0,10,length.out = 100)             # independent variable
sig <- exp(0.5 + 0.15*x2)                    # non-constant variance
b_0 <- 10                                    # true intercept
b_1 <- 0.15                                  # true slope
set.seed(17221)                              # make the next line reproducible
e <- rnorm(100,mean = 0, sd = sig)           # normal random error with non-constant variance
y <- b_0 + b_1*x2 + e                        # dependent variable

## Data
ndata <- data.frame(y = y, x2 = x2)

## Some percentiles of interest
percentile <- c(10, 25, 50, 90)

## Normal quantile regression, zero = NULL
fit1 <- vglm(Q.reg(y, length.arg = 4) ~ x2, 
             uninormalff(link1 = "uninormalQlink", percentile = percentile, zero = NULL), 
             data = ndata, trace = TRUE)
#summary(fit1)
( my.coef3Q <- coef(fit1, mat = TRUE) )

## Plots - percentile curves.
plot(y ~ x2, pch = 19, ylim = c(-1, 25), 
main =" Normal quantile regression")
abline(h = -3:25, v = 0, col = "gray", lty = "dashed")
with(ndata, lines(x2, my.coef3Q[1, 1] + my.coef3Q[2, 1] * x2, 
                  col = "red", lty = "dotted", lwd = 4))
with(ndata, lines(x2, my.coef3Q[1, 3] + my.coef3Q[2, 3] * x2, 
                  col = "orange", lty = "dotted", lwd = 4))
with(ndata, lines(x2, my.coef3Q[1, 5] + my.coef3Q[2, 5] * x2, 
                  col = "blue", lty = "dotted", lwd = 4))
with(ndata, lines(x2, my.coef3Q[1, 7] + my.coef3Q[2, 7] * x2, 
                  col = "brown", lty = "dotted", lwd = 4))
legend("topleft", c("90th", "50th", "25th", "10th"),
col = c("brown", "blue", "orange", "red"), lty = rep("dotted", 4), lwd = rep(4, 4))


## Mimicking 'VGAM:uninormal'
fit2 <- vglm(y ~ x2,  uninormalff(link1 = "identitylink", percentile = NULL, zero = NULL), 
             data = ndata, trace = TRUE)

     
## End(Not run)

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