optPenaltyGLMmultiT.kCVauto {porridge} | R Documentation |
Automatic search for optimal penalty parameters of the targeted ridge GLM estimator.
Description
Function finds the optimal penalty parameter of the targeted ridge regression estimator of the generalized linear model parameter. The optimum is defined as the minimizer of the cross-validated loss associated with the estimator.
Usage
optPenaltyGLMmultiT.kCVauto(Y, X, lambdaInit, model="linear", targetMat,
folds=makeFoldsGLMcv(min(10, length(X)), Y, model=model),
loss="loglik", lambdaMin=10^(-5),
minSuccDiff=10^(-5), maxIter=100)
Arguments
Y |
A |
X |
The design |
lambdaInit |
A |
model |
A |
targetMat |
A |
folds |
A |
loss |
A |
lambdaMin |
A positive |
minSuccDiff |
A |
maxIter |
A |
Value
The function returns an all-positive numeric
, the cross-validated optimal penalty parameters. The average loglikelihood over the left-out samples is used as the cross-validation criterion. If model="linear"
, also the average sum-of-squares over the left-out samples is offered as cross-validation criterion.
Author(s)
W.N. van Wieringen.
References
van Wieringen, W.N. Binder, H. (2022), "Sequential learning of regression models by penalized estimation", accepted.
Examples
# set the sample size
n <- 50
# set the true parameter
betas <- (c(0:100) - 50) / 20
# generate covariate data
X <- matrix(rnorm(length(betas)*n), nrow=n)
# sample the response
probs <- exp(tcrossprod(betas, X)[1,]) / (1 + exp(tcrossprod(betas, X)[1,]))
Y <- numeric()
for (i in 1:n){
Y <- c(Y, sample(c(0,1), 1, prob=c(1-probs[i], probs[i])))
}
# create targets
targets <- cbind(betas/2, rep(0, length(betas)))
# tune the penalty parameter
### optLambdas <- optPenaltyGLMmultiT.kCVauto(Y, X, c(50,0.1), fold=5,
### targetMat=targets, model="logistic",
### minSuccDiff=10^(-3))
# estimate the logistic regression parameter
### bHat <- ridgeGLMmultiT(Y, X, lambdas=optLambdas, targetMat=targets, model="logistic")