optLambdas_mgcv {multiridge} | R Documentation |
Find optimal ridge penalties with maximimum marginal likelihood
Description
Optimizes a marginal likelihood score w.r.t. ridge penalties for multiple data blocks.
Usage
optLambdas_mgcv(penaltiesinit=NULL, XXblocks,Y, pairing=NULL, model=NULL, reltol=1e-4,
optmethod=ifelse(length(penaltiesinit)==1,"Brent", "Nelder-Mead"),maxItropt=500,
tracescore=TRUE, fixedpen=NULL, fixedseed =TRUE, sigmasq = 1,
opt.sigma=ifelse(model=="linear",TRUE, FALSE))
Arguments
penaltiesinit |
Numeric vector. Initial values for penaltyparameters. May be obtained from |
XXblocks |
List of |
Y |
Response vector: numeric, binary, factor or |
pairing |
Numerical vector of length 3 or |
model |
Character. Any of |
reltol |
Scalar. Relative tolerance for optimization methods. |
optmethod |
Character. Optimization method. Any of the methods |
maxItropt |
Integer. Maximum number of iterations for |
tracescore |
Boolean. Should the output of the scores be traced? |
fixedpen |
Integer vector or |
fixedseed |
Boolean. Should the initialization be fixed? For reproducibility. |
sigmasq |
Default error variance. |
opt.sigma |
Boolean. Should the error variance be optimized as well? Only relevant for |
Details
See gam
for details on how the marginal likelihood is computed.
Value
List, with components:
optres |
Output of the optimizer |
optpen |
Vector with determined optimal penalties |
allsc |
Matrix with marginal likelihood scores for all penalty parameter configurations used by the optimizer |
See Also
optLambdas_mgcvWrap
for i) (recommended) optimization in two steps: first global, then local; and ii) sequential optimization
when some data types are preferred over others. 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)
# Compute cross-validated score for initial lambdas
CVscore(penalties=lambdas, XXblocks=XXmirmeth,Y=resp,folds=leftout,
score="loglik")
# Optimize by using marginal likelihood criterion
jointlambdas2 <- optLambdas_mgcvWrap(penaltiesinit=lambdas, XXblocks=XXmirmeth,
Y=resp)
# Optimal lambdas
optlambdas <- jointlambdas2$optpen