logreg.ridge.cv: logreg.ridge.cv

Description Usage Arguments Value Examples

View source: R/logreg.ridge.cv.R

Description

This function logreg.ridge.cv() works to perform cross-validation to select the best lambda

Usage

1
logreg.ridge.cv(y, X, lambdas, nfolds = 5, plot = F)

Arguments

y

the input y as response

X

the input X to fit model

lambdas

a vector specifies the lambda candidates

nfolds

an int sepecific how many folds you want to split the data

plot

this boolean variable specifies if you want to plot the result

Value

the function will return a list of following elements: lambda.min, the best lambda in the candidates; err the error list corresponding to the lambda vector, and lambda.vec specifies the lambda vector as input

Examples

1
2
3
4
x=matrix(rnorm(100),20,5)
y=sample(c(0,1),20,replace=TRUE)
lambdas=c(0.1,0.004,0.7,4)
logreg.ridge.cv(y,x,lambdas,plot=TRUE)

chenyn16/LogisticRidge documentation built on Dec. 31, 2020, 9:58 p.m.