Description Usage Arguments Details Value Note Author(s) References See Also Examples
This package implements a penalized Frumento and Bottai's (2015) method for quantile regression coefficient modeling (qrcm), in which quantile regression coefficients are described by (flexible) parametric functions of the order of the quantile. This package fits lasso qrcm using coordinate descent.
1 2 |
formula |
a two-sided formula of the form |
formula.p |
a one-sided formula of the form |
weights |
an optional vector of weights to be used in the fitting process. |
data |
an optional data frame, list or environment containing the variables in |
s |
an optional 0/1 matrix that permits excluding some model coefficients (see ‘Examples’). |
nl |
the number of lambda values - default is 70. |
display |
if TRUE something is printed - default is TRUE. |
tol |
convergence criterion for numerical optimization - default is 1e-6. |
maxit |
maximum number of iterations - default is 100. |
Quantile regression permits modeling conditional quantiles of a response variabile, given a set of covariates. A linear model is used to describe the conditional quantile function:
Q(p | x) = β0(p) + β1(p)*x1 + β2(p)*x2 + ….
The model coefficients β(p) describe the effect of covariates on the p-th quantile of the response variable. Usually, one or more quantiles are estimated, corresponding to different values of p.
Assume that each coefficient can be expressed as a parametric function of p of the form:
β(p | θ) = θ0 + θ1*b1(p) + θ2*b2(p) + …
where b1(p), b2(p), … are known functions of p. If q is the dimension of x = (1, x1, x2, …) and k is that of b(p) = (1, b1(p), b2(p), …), the entire conditional quantile function is described by a q*k matrix θ of model parameters.
Users are required to specify two formulas: formula
describes the regression model,
while formula.p
identifies the 'basis' b(p).
By default, formula.p = ~ slp(p, k = 3)
, a 3rd-degree shifted
Legendre polynomial (see slp
). Any user-defined function b(p, …)
can be used, see ‘Examples’.
Estimation of penalized θ is carried out by minimizing a penalized integrated loss function,
corresponding to the integral, over p, of the penalized loss function of standard quantile regression. This
motivates the acronym piqr
(penalized integrated quantile regression).
See details in iqr
An object of class “piqr
”, a list containing the following items:
call |
the matched call. |
lambda |
The actual sequence of lambda values used. |
coefficients |
a list of estimated model parameters describing the fitted quantile function along the path. |
minimum |
the value of the minimized integrated loss function for each value of lambda. |
dl |
a matrix of gradient values along the path. |
df |
The number of nonzero coefficients for each value of lambda. |
seqS |
a list containg each matrix s for each value of lambda. |
internal |
a list containing some initial object. |
By expressing quantile regression coefficients as functions of p, a parametric model for the conditional
quantile function is specified. The induced PDF and CDF can be used as diagnostic tools.
Negative values of PDF
indicate quantile crossing, i.e., the conditional quantile function is not
monotonically increasing. Null values of PDF
indicate observations that lie outside the
estimated support of the data, defined by quantiles of order 0 and 1. If null or negative PDF
values occur for a relatively large proportion of data, the model is probably misspecified or ill-defined.
If the model is correct, the fitted CDF
should approximately follow a Uniform(0,1) distribution.
This idea is used to implement a goodness-of-fit test, see summary.iqr
and test.fit
.
The intercept can be excluded from formula
, e.g.,
iqr(y ~ -1 + x)
. This, however, implies that when x = 0
,
y
is always 0. See example 5 in ‘Examples’.
The intercept can also be removed from formula.p
.
This is recommended if the data are bounded. For example, for strictly positive data,
use iqr(y ~ 1, formula.p = -1 + slp(p,3))
to force the smallest quantile
to be zero. See example 6 in ‘Examples’.
Gianluca Sottile gianluca.sottile@unipa.it
Frumento, P., and Bottai, M. (2015). Parametric modeling of quantile regression coefficient functions. Biometrics, doi: 10.1111/biom.12410.
summary.piqr
, plot.piqr
, predict.piqr
,
for summary, plotting, and prediction.
gof.piqr
to select the best value of the tuning parameter though AIC, BIC, GIC, GCV criteria.
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 31 32 33 34 35 36 37 38 39 40 41 42 | ##### Using simulated data in all examples
##### Example 1
n <- 1000
x <- runif(n)
y <- rnorm(n, 1 + x, 1 + x)
# true quantile function: Q(p | x) = beta0(p) + beta1(p)*x, with
# beta0(p) = beta1(p) = 1 + qnorm(p)
# fit the true model: b(p) = (1 , qnorm(p))
m1 <- piqr(y ~ x, formula.p = ~ I(qnorm(p)))
best1 <- gof.piqr(m1, method="AIC", plot=FALSE)
# the fitted quantile regression coefficient functions are
# beta0(p) = m1$coef[1,1] + m1$coef[1,2]*qnorm(p)
# beta1(p) = m1$coef[2,1] + m1$coef[2,2]*qnorm(p)
# a basis b(p) = (1, p), i.e., beta(p) is assumed to be a linear function of p
m2 <- piqr(y ~ x, formula.p = ~ p)
best2 <- gof.piqr(m2, method="AIC", plot=FALSE)
# a 'rich' basis b(p) = (1, p, p^2, log(p), log(1 - p))
m3 <- piqr(y ~ x, formula.p = ~ p + I(p^2) + I(log(p)) + I(log(1 - p)))
best3 <- gof.piqr(m3, method="AIC", plot=FALSE)
# 'slp' creates an orthogonal spline basis using shifted Legendre polynomials
m4 <- piqr(y ~ x, formula.p = ~ slp(p, k = 3)) # note that this is the default
best4 <- gof.piqr(m4, method="AIC", plot=FALSE)
# 'plf' creates the basis of a piecewise linear function
m5 <- piqr(y ~ x, formula.p = ~ plf(p, knots = c(0.1,0.9)))
best5 <- gof.piqr(m5, method="AIC", plot=FALSE)
summary(m4, best4$minLambda)
par(mfrow = c(2,2))
plot(m4, xvar="norm")
plot(m4, xvar="lambda")
plot(m4, xvar="objective")
plot(m4, xvar="grad")
# see the documentation for 'summary.piqr', and 'plot.piqr'
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.