Quantile Ratio Regression
qrr.RdThis function fits a quantile ratio regression model
Usage
qrr(formula, data, taus, start = "rq", beta = NULL,
tsf = "bc", symm = TRUE, dbounded = FALSE, linearize = TRUE,
kernel = "Gaussian", maxIter = 10, epsilon = 1e-05,
verbose = FALSE, method.rq = "fn", method.nlrq = "L-BFGS-B")Arguments
- formula
a formula object, with the response on the left of a
~operator, and the terms, separated by+operators, on the right.- data
a data frame in which to interpret the variables named in the formula.
- taus
a vector of two quantiles for the ratio to be estimated (the order is irrelevant).
- start
the algorithm with which obtain the starting values for one of the quantiles in the ratio. Possible options are
"rq"(linear regression model – seerq),"tsrq"(quantile regression transformation model – seetsrq),"conquer"(fast linear regression model – seeconquer),"llqr"(nonparametric linear regression model – seellqr)- beta
starting values for the regression coefficients. If left
NULL, these are set to 0.- tsf
if
start = "tsrq", seetsrq.- symm
if
start = "tsrq", seetsrq.- dbounded
if
start = "tsrq", seetsrq.- linearize
logical flag. If
TRUE(default), estimation is carried out with the linearized iterative algorithm of Farcomeni and Geraci (2023) by repeated calls to an appropriate linear estimation algorithm. Otherwise, the algorithm calls a nonlinear estimation routine. See argumentmethod.rqandmethod.nlrqfurther below.- kernel
an optional vector of weights to be used in the fitting process. Should be NULL or a numeric vector.
- maxIter
maximum number of iterations for fitting.
- epsilon
tolerance for convergence.
- verbose
logical flag. If
TRUE, progress on estimation is print out.- method.rq
the method used to compute the linear fit. If
linearize = TRUE, the options are"conquer"or any of those fromrq(see the argumentmethod).- method.nlrq
the method used to compute the nonlinear fit. If
linearize = FALSE, the options are those fromnlrq(see the argumentmethod).
Details
These function implements quantile ratio regression as discussed by Farcomeni and Geraci (see references). The general model is assumed to be \(g(Q_{Y|X}(\tau_{1})/Q_{Y|X}(\tau_{2})) = \eta = Xb\) where \(Q\) denotes the conditional quantile function, \(Y\) is the response variable, \(X\) a design matrix, \(g\) is a monotone link function, and \(\tau_{1}\) and \(\tau_{2}\) the levels of the two quantiles in the ratio. In the current implementation, \(g(u) = log(u - 1)\), which ensures monotonocity (non-crossing) of the quantiles and leads to the familiar interpretation of the inverse logistic transformation.
Examples
set.seed(123)
n <- 5000
x <- runif(n, -0.5, 0.5)
R <- 1 + exp(0.5 + 0.5*x)
# fit quintile ratio regression
alpha <- 1/log(R)*log(log(1-0.8)/log(1-0.2))
y <- rweibull(n, shape = alpha, scale = 1)
dd <- data.frame(x = x, y = y)
qrr(y ~ x, data = dd, taus = c(.2,.8))
#> Algorithm converged
#>
#> Quantile ratio regression 0.8:0.2
#>
#> Coefficients linear predictor:
#> (Intercept) x
#> 0.4650384 0.2952071
#>
#> Degrees of freedom: 5000 total; 4998 residual
# fit Palma ratio regression
alpha <- 1/log(R)*log(log(1-0.9)/log(1-0.4))
y <- rweibull(n, shape = alpha, scale = 1)
dd <- data.frame(x = x, y = y)
qrr(y ~ x, data = dd, taus = c(.4,.9))
#> Algorithm converged
#>
#> Quantile ratio regression 0.9:0.4
#>
#> Coefficients linear predictor:
#> (Intercept) x
#> 0.4582485 0.5437684
#>
#> Degrees of freedom: 5000 total; 4998 residual