cv.glmpath {glmpath}R Documentation

Computes cross-validated (minus) log-likelihoods or prediction errors for glmpath

Description

This function computes cross-validated (minus) log-likelihoods or prediction errors for glmpath.

Usage

  cv.glmpath(x, y, data, family = binomial, weight = rep(1, n),
             offset = rep(0, n), nfold = 10,
             fraction = seq(0, 1, length = 100),
             type = c("loglik", "response"), mode = c("norm", "lambda"),
             plot.it = TRUE, se = TRUE, ...)

Arguments

x

matrix of features

y

response

data

a list consisting of x: a matrix of features and y: response. data is not needed if above x and y are input separately.

family

name of a family function that represents the distribution of y to be used in the model. It must be binomial, gaussian, or poisson. For each one, the canonical link function is used; logit for binomial, identity for gaussian, and log for poisson distribution. Default is binomial.

weight

an optional vector of weights for observations

offset

an optional vector of offset. If a column of x is used as offset, the corresponding column must be excluded from x.

nfold

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

fraction

the fraction of L1 norm or log(\lambda) with respect to their maximum values at which the CV errors are computed. Default is seq(0,1,length=100).

type

If type=loglik, cross-validated minus log-likelihoods are computed. If type=response, cross-validated prediction errors are computed. Default is loglik.

mode

If mode=norm, cross-validation is run at certain values of L1 norm. If mode=lambda, cross-validation is run at certain values of log(\lambda). Default is norm.

plot.it

If TRUE, CV curve is plotted.

se

If TRUE, standard errors are plotted.

...

other options for glmpath

Author(s)

Mee Young Park and Trevor Hastie

References

Mee Young Park and Trevor Hastie (2007) L1 regularization path algorithm for generalized linear models. J. R. Statist. Soc. B, 69, 659-677.

See Also

glmpath, plot.glmpath, predict.glmpath

Examples

data(heart.data)
attach(heart.data)
cv.a <- cv.glmpath(x, y, family=binomial)
cv.b <- cv.glmpath(x, y, family=binomial, type="response")
detach(heart.data)

[Package glmpath version 0.98 Index]