Learn R Programming

stepPlr (version 0.93)

cv.step.plr: Computes cross-validated deviance or prediction errors for step.plr

Description

This function computes cross-validated deviance or prediction errors for step.plr. The parameters that can be cross-validated are lambda and cp.

Usage

cv.step.plr(x, y, weights = rep(1, length(y)),
              nfold = 5, folds = NULL, lambda = c(1e-4, 1e-2, 1),
              cp = c("aic", "bic"), cv.type=c("deviance", "class"),
              trace = TRUE, ...)

Arguments

x

matrix of features

y

binary response

weights

optional vector of weights for observations

nfold

number of folds to be used in cross-validation. Default is nfold=5.

folds

list of cross-validation folds. Its length must be nfold. If NULL, the folds are randomly generated.

lambda

vector of the candidate values for lambda in step.plr

cp

vector of the candidate values for cp in step.plr

cv.type

If cv.type=deviance, cross-validated deviances are returned. If cv.type=class, cross-validated prediction errors are returned.

trace

If TRUE, the steps are printed out.

...

other options for step.plr

Details

This function computes cross-validated deviance or prediction errors for step.plr. The parameters that can be cross-validated are lambda and cp. If both are input as vectors (of length greater than 1), then a two-dimensional cross-validation is done. If either one is input as a single value, then the cross-validation is done only on the parameter with multiple inputs.

References

Mee Young Park and Trevor Hastie (2008) Penalized Logistic Regression for Detecting Gene Interactions

See Also

step.plr

Examples

Run this code
# NOT RUN {
n <- 100
p <- 5
x <- matrix(sample(seq(3), n * p, replace=TRUE), nrow=n)
y <- sample(c(0, 1), n, replace=TRUE)
level <- vector("list", length=p)
for (i in 1:p) level[[i]] <- seq(3)
cvfit <- cv.step.plr(x, y, level=level, lambda=c(1e-4, 1e-2, 1), cp="bic")
# }

Run the code above in your browser using DataLab