kerndwd {kerndwd} | R Documentation |
solve Linear DWD and Kernel DWD
Description
Fit the linear generalized distance weighted discrimination (DWD) model and the generalized DWD on Reproducing kernel Hilbert space. The solution path is computed at a grid of values of tuning parameter lambda
.
Usage
kerndwd(x, y, kern, lambda, qval=1, wt, eps=1e-05, maxit=1e+05)
Arguments
x |
A numerical matrix with |
y |
A vector of length |
kern |
A kernel function; see |
lambda |
A user supplied |
qval |
The exponent index of the generalized DWD. Default value is 1. |
wt |
A vector of length |
eps |
The algorithm stops when (i.e. |
maxit |
The maximum of iterations allowed. Default is 1e5. |
Details
Suppose that the generalized DWD loss is V_q(u)=1-u
if u \le q/(q+1)
and \frac{1}{u^q}\frac{q^q}{(q+1)^{(q+1)}}
if u > q/(q+1)
. The value of \lambda
, i.e., lambda
, is user-specified.
In the linear case (kern
is the inner product and N > p), the kerndwd
fits a linear DWD by minimizing the L2 penalized DWD loss function,
\frac{1}{N}\sum_{i=1}^n V_q(y_i(\beta_0 + X_i'\beta)) + \lambda \beta' \beta.
If a linear DWD is fitted when N < p, a kernel DWD with the linear kernel is actually solved. In such case, the coefficient \beta
can be obtained from \beta = X'\alpha.
In the kernel case, the kerndwd
fits a kernel DWD by minimizing
\frac{1}{N}\sum_{i=1}^n V_q(y_i(\beta_0 + K_i' \alpha)) + \lambda \alpha' K \alpha,
where K
is the kernel matrix and K_i
is the ith row.
The weighted linear DWD and the weighted kernel DWD are formulated as follows,
\frac{1}{N}\sum_{i=1}^n w_i \cdot V_q(y_i(\beta_0 + X_i'\beta)) + \lambda \beta' \beta,
\frac{1}{N}\sum_{i=1}^n w_i \cdot V_q(y_i(\beta_0 + K_i' \alpha)) + \lambda \alpha' K \alpha,
where w_i
is the ith element of wt
. The choice of weight factors can be seen in the reference below.
Value
An object with S3 class kerndwd
.
alpha |
A matrix of DWD coefficients at each |
lambda |
The |
npass |
Total number of MM iterations for all lambda values. |
jerr |
Warnings and errors; 0 if none. |
info |
A list including parameters of the loss function, |
call |
The call that produced this object. |
Author(s)
Boxiang Wang and Hui Zou
Maintainer: Boxiang Wang boxiang-wang@uiowa.edu
References
Wang, B. and Zou, H. (2018)
“Another Look at Distance Weighted Discrimination,"
Journal of Royal Statistical Society, Series B, 80(1), 177–198.
https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12244
Karatzoglou, A., Smola, A., Hornik, K., and Zeileis, A. (2004)
“kernlab – An S4 Package for Kernel Methods in R",
Journal of Statistical Software, 11(9), 1–20.
https://www.jstatsoft.org/v11/i09/paper
Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized
linear models via coordinate descent," Journal of Statistical Software, 33(1), 1–22.
https://www.jstatsoft.org/v33/i01/paper
Marron, J.S., Todd, M.J., and Ahn, J. (2007)
“Distance-Weighted Discrimination"",
Journal of the American Statistical Association, 102(408), 1267–1271.
https://www.tandfonline.com/doi/abs/10.1198/016214507000001120
Qiao, X., Zhang, H., Liu, Y., Todd, M., Marron, J.S. (2010)
“Weighted distance weighted discrimination and its asymptotic properties",
Journal of the American Statistical Association, 105(489), 401–414.
https://www.tandfonline.com/doi/abs/10.1198/jasa.2010.tm08487
See Also
predict.kerndwd
, plot.kerndwd
, and cv.kerndwd
.
Examples
data(BUPA)
# standardize the predictors
BUPA$X = scale(BUPA$X, center=TRUE, scale=TRUE)
# a grid of tuning parameters
lambda = 10^(seq(3, -3, length.out=10))
# fit a linear DWD
kern = vanilladot()
DWD_linear = kerndwd(BUPA$X, BUPA$y, kern,
qval=1, lambda=lambda, eps=1e-5, maxit=1e5)
# fit a DWD using Gaussian kernel
kern = rbfdot(sigma=1)
DWD_Gaussian = kerndwd(BUPA$X, BUPA$y, kern,
qval=1, lambda=lambda, eps=1e-5, maxit=1e5)
# fit a weighted kernel DWD
kern = rbfdot(sigma=1)
weights = c(1, 2)[factor(BUPA$y)]
DWD_wtGaussian = kerndwd(BUPA$X, BUPA$y, kern,
qval=1, lambda=lambda, wt = weights, eps=1e-5, maxit=1e5)