# NOT RUN {
set.seed(14)
beta <- c(3, 2, -1.6, -4)
noise <- 5
simData <- SimData(N=100, beta=beta, noise=noise, corr=TRUE)
nfolds <- 3
grid <- expand.grid(w = c( 0.3, 0.7),
lamda = c(1.5))
before <- Sys.time()
paramCV <- tuneParam(simData, nfolds, grid, algorithm=c("QN"))
(totalTime <- Sys.time() - before)
maxAUC <- paramCV[which.max(paramCV$AUC),]$AUC
allmaxAUC <- paramCV[which(paramCV$AUC==maxAUC),] # checks if the value of AUC
# is unique; if is not unique then it will take the combination of lamda and
# w where lamda has the largest value- thus achieving higher sparsity
runQN <- optimPenaLik(simData, lamda= allmaxAUC[nrow(allmaxAUC),]$lamda,
w= allmaxAUC[nrow(allmaxAUC),]$w,
algorithms=c("QN"))
(coefQN <- runQN$varQN)
# check the robustness of the choice of lamda
runQN2 <- optimPenaLik(simData, lamda= allmaxAUC[1,]$lamda,
w= allmaxAUC[1,]$w,
algorithms=c("QN"))
(coefQN2 <- runQN2$varQN)
# }
Run the code above in your browser using DataLab