Description Usage Arguments Details Value Author(s) References See Also Examples
The function performs a kernel logistic regression for binary outputs.
1 2 |
X |
a design matrix with dimension |
y |
a response vector with length |
xnew |
a testing matrix with dimension |
lambda |
a positive value specifing the tuning parameter for KLR. The default is 0.01. |
kernel |
"matern" or "exponential" which specifies the matern kernel or power exponential kernel. The default is "matern". |
nu |
a positive value specifying the order of matern kernel if |
power |
a positive value (between 1.0 and 2.0) specifying the power of power exponential kernel if |
rho |
a positive value specifying the scale parameter of matern and power exponential kernels. The default is 0.1. |
This function performs a kernel logistic regression, where the kernel can be assigned to Matern kernel or power exponential kernel by the argument kernel
. The arguments power
and rho
are the tuning parameters in the power exponential kernel function, and nu
and rho
are the tuning parameters in the Matern kernel function. The power exponential kernel has the form
K_{ij}=\exp(-\frac{∑_{k}{|x_{ik}-x_{jk}|^{power}}}{rho}),
and the Matern kernel has the form
K_{ij}=∏_{k}\frac{1}{Γ(nu)2^{nu-1}}(2√{nu}\frac{|x_{ik}-x_{jk}|}{rho})^{nu} κ(2√{nu}\frac{|x_{ik}-x_{jk}|}{rho}).
The argument lambda
is the tuning parameter for the function smoothness.
Predictive probabilities at given locations xnew
.
Chih-Li Sung <iamdfchile@gmail.com>
Zhu, J. and Hastie, T. (2005). Kernel logistic regression and the import vector machine. Journal of Computational and Graphical Statistics, 14(1), 185-205.
cv.KLR
for performing cross-validation to choose the tuning parameters.
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 | library(calibrateBinary)
set.seed(1)
np <- 10
xp <- seq(0,1,length.out = np)
eta_fun <- function(x) exp(exp(-0.5*x)*cos(3.5*pi*x)-1) # true probability function
eta_x <- eta_fun(xp)
yp <- rep(0,np)
for(i in 1:np) yp[i] <- rbinom(1,1, eta_x[i])
x.test <- seq(0,1,0.001)
etahat <- KLR(xp,yp,x.test)
plot(xp,yp)
curve(eta_fun, col = "blue", lty = 2, add = TRUE)
lines(x.test, etahat, col = 2)
##### cross-validation with K=5 #####
##### to determine the parameter rho #####
cv.out <- cv.KLR(xp,yp,K=5)
print(cv.out)
etahat.cv <- KLR(xp,yp,x.test,lambda=cv.out$lambda,rho=cv.out$rho)
plot(xp,yp)
curve(eta_fun, col = "blue", lty = 2, add = TRUE)
lines(x.test, etahat, col = 2)
lines(x.test, etahat.cv, col = 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.