Description Usage Arguments Details Value Author(s) See Also Examples
The function performs k-fold cross validation for kernel logistic regression to estimate tuning parameters.
1 2 |
X |
input for |
y |
input for |
K |
a positive integer specifying the number of folds. The default is 5. |
lambda |
a vector specifying lambda values at which CV curve will be computed. |
kernel |
input for |
nu |
input for |
power |
input for |
rho |
rho value at which CV curve will be computed. |
This function performs the k-fold cross-valibration for a kernel logistic regression. The CV curve is computed at the values of the tuning parameters assigned by lambda
and rho
. The number of fold is given by K
.
lambda |
value of |
rho |
value of |
Chih-Li Sung <iamdfchile@gmail.com>
KLR
for performing a kernel logistic regression with given lambda
and rho
.
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.