optLambdasWrap {multiridge} | R Documentation |
Find optimal ridge penalties with sequential optimization.
Description
Sequentially optimizes a cross-validated score w.r.t. ridge penalties for multiple data blocks. Also implements preferential ridge, which allows to first optimize for the preferential data types.
Usage
optLambdasWrap(penaltiesinit = NULL, XXblocks, Y, X1 = NULL, pairing = NULL,
folds, intercept = ifelse(is(Y, "Surv"), FALSE, TRUE), frac1 = NULL,
score = "loglik", model = NULL, epsIWLS = 0.001, maxItrIWLS = 25,
traceCV = TRUE, reltol = 1e-04, optmethod1 = "SANN", optmethod2 =
ifelse(length(penaltiesinit) == 1, "Brent", "Nelder-Mead"), maxItropt1 = 10,
maxItropt2 = 25, save = FALSE, parallel = FALSE, pref = NULL, fixedpen = NULL)
Arguments
penaltiesinit |
Numeric vector. Initial values for penaltyparameters. May be obtained from |
XXblocks |
List of |
Y |
Response vector: numeric, binary, factor or |
X1 |
Matrix. Dimension |
pairing |
Numerical vector of length 3 or |
folds |
List, containing the splits of the samples. Usually obtained by
|
intercept |
Boolean. Should an intercept be included? |
frac1 |
Scalar. Prior fraction of cases. Only relevant for |
score |
Character. See Details. |
model |
Character. Any of |
epsIWLS |
Scalar. Numerical bound for IWLS convergence. |
maxItrIWLS |
Integer. Maximum number of iterations used in IWLS. |
traceCV |
Boolean. Should the output of the IWLS algorithm be traced? |
reltol |
Scalar. Relative tolerance for optimization methods. |
optmethod1 |
Character. First, global search method. Any of the methods |
optmethod2 |
Character. Second, local search method. Any of the methods |
maxItropt1 |
Integer. Maximum number of iterations for |
maxItropt2 |
Integer. Maximum number of iterations for |
save |
Boolean. If TRUE appends the penalties and resulting CVscore to global variable |
parallel |
Boolean. Should computation be done in parallel? If |
pref |
Integer vector or |
fixedpen |
Integer vector or |
Details
As opposed to optLambdas
this function first searches globally,
then locally.
Hence, more time-consuming, but better guarded against multiple local optima.
See Scoring
for details on score
. We highly recommend to
use smooth scoring functions, in particular "loglik"
.
For ranking-based criteria like "auc"
and "cindex"
we advise to
use repeated CV (see CVfolds
) to avoid ending up in any of the
many local optima.
Value
List, with components:
res |
Outputs of all optimizers used |
lambdas |
List of penalties found by the optimizers |
optpen |
Numerical vector with final, optimal penalties |
See Also
optLambdas
for one-pass optimization. fastCV2
for initialization of penalties.A full demo and data are available from:
https://drive.google.com/open?id=1NUfeOtN8-KZ8A2HZzveG506nBwgW64e4
Examples
data(dataXXmirmeth)
resp <- dataXXmirmeth[[1]]
XXmirmeth <- dataXXmirmeth[[2]]
# Find initial lambdas: fast CV per data block separately.
cvperblock2 <- fastCV2(XXblocks=XXmirmeth,Y=resp,kfold=10,fixedfolds = TRUE)
lambdas <- cvperblock2$lambdas
# Create (repeated) CV-splits of the data.
leftout <- CVfolds(Y=resp,kfold=10,nrepeat=3,fixedfolds = TRUE)
# Optimizes cross-validate criterion (default: log-lik)
# Increase the number of iterations for optimal results
jointlambdas <- optLambdasWrap(penaltiesinit=lambdas, XXblocks=XXmirmeth,Y=resp,
folds=leftout,score="loglik",save=T,maxItropt1=5, maxItropt2=5)