This package provides tools for fitting kernel quantile regression.
The strengths and improvements that this package offers relative to other quantile regression packages are as follows:
Compiled Fortran code significantly speeds up the kernel quantile regression estimation process.
Solve non-crossing kernel quantile regression.
For this getting-started vignette, first, we will use a real data set
named as GAGurine
in the package MASS
, which
collects the concentration of chemical GAGs in the urine of 314 children
aged 0 to 17 years. We used the concentration of GAG as the response
variable.
Then the kernel quantile regression model is formulated as the sum of check loss and an ℓ2 penalty:
$$ \min_{\alpha\in\mathbb{R}^{n},b\in\mathbb{R}}\frac{1}{n} \sum_{i=1}^{n}\rho_{\tau}(y_{i}-b-\mathbf{K}_{i}^{\top}\alpha) +\frac{\lambda}{2} \alpha^{\top}\mathbf{K}\alpha \qquad (*). $$
kqr()
Given an input matrix x
, a quantile level
tau
, and a response vector y
, a kernel
quantile regression model is estimated for a sequence of penalty
parameter values. The other main arguments the users might supply
are:
lambda
: a user-supplied lambda
sequence.is_exact
: exact or approximated solutions.cv.kqr()
This function performs k-fold cross-validation (cv). It takes the
same arguments as kqr
.
A number of S3 methods are provided for nckqr
object.
coef()
and predict()
return a matrix of
coefficients and predictions ŷ
given a matrix x
at each lambda respectively. The optional
s
argument may provide a specific value of λ (not necessarily part of the
original sequence).nckqr()
Given an input matrix x
, a sequence of quantile levels
tau
, and a response vector y
, a non-crossing
kernel quantile regression model is estimated for two sequences of
penalty parameter values. It takes the same arguments x
,
y
,is_exact
, which are specified above. The
other main arguments the users might supply are:
lambda2
: a user-supplied lambda1
sequence for the L2 penalty.
lambda1
: a user-supplied lambda2
sequence for the smooth ReLU penalty.
cv.nckqr()
This function performs k-fold cross-validation (cv) for selecting the
tuning parameter ‘lambda2’ of non-crossing kernel quantile regression.
It takes the same arguments as nckqr
.
l2_list <- 10^(seq(1, -4, length.out=10))
cv.fit1 <- cv.nckqr(x, y, lambda1=10, lambda2=l2_list, tau=tau)
A number of S3 methods are provided for nckqr
object.
coef()
and predict()
return an array of
coefficients and predictions ŷ
given a matrix X
and lambda2
at each lambda1
respectively. The optional s1
argument may provide a
specific value of λ1 (not necessarily part
of the original sequence).coef <- coef(fit1, s2=1e-4, s1 = l1_list[2:3])
predict(fit1, x, tail(x), s1=l1_list[1:3], s2=l2)
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 2.156783 2.437642 2.265022
#> [2,] 1.872422 1.921243 1.936153
#> [3,] 1.833562 1.962324 2.183077
#> [4,] 1.839793 2.187164 2.816320
#> [5,] 1.914857 2.510885 3.526075
#> [6,] 3.429429 5.942843 9.185686
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 2.156781 2.437617 2.265047
#> [2,] 1.872418 1.921228 1.936166
#> [3,] 1.833559 1.962314 2.183085
#> [4,] 1.839790 2.187162 2.816320
#> [5,] 1.914855 2.510889 3.526070
#> [6,] 3.429431 5.942845 9.185685
#>
#> , , 3
#>
#> [,1] [,2] [,3]
#> [1,] 2.156745 2.436776 2.265679
#> [2,] 1.872316 1.920578 1.936479
#> [3,] 1.833467 1.961874 2.183233
#> [4,] 1.839730 2.187076 2.816230
#> [5,] 1.914830 2.511075 3.525834
#> [6,] 3.429600 5.943594 9.185657