qrr.Rd
This function fits a quantile ratio regression model
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")
a formula object, with the response on the left of a ~
operator, and the terms, separated by +
operators, on the right.
a data frame in which to interpret the variables named in the formula.
a vector of two quantiles for the ratio to be estimated (the order is irrelevant).
the algorithm with which obtain the starting values for one of the quantiles in the ratio. Possible options are "rq"
(linear regression model – see rq
), "tsrq"
(quantile regression transformation model – see tsrq
), "conquer"
(fast linear regression model – see conquer
), "llqr"
(nonparametric linear regression model – see llqr
)
starting values for the regression coefficients. If left NULL
, these are set to 0.
if start = "tsrq"
, see tsrq
.
if start = "tsrq"
, see tsrq
.
if start = "tsrq"
, see tsrq
.
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 argument method.rq
and method.nlrq
further below.
an optional vector of weights to be used in the fitting process. Should be NULL or a numeric vector.
maximum number of iterations for fitting.
tolerance for convergence.
logical flag. If TRUE
, progress on estimation is print out.
the method used to compute the linear fit. If linearize = TRUE
, the options are "conquer"
or any of those from rq
(see the argument method
).
the method used to compute the nonlinear fit. If linearize = FALSE
, the options are those from nlrq
(see the argument method
).
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.
Farcomeni A. and Geraci M. Quantile ratio regression. 2023. Working Paper.
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