This function computes cross-validated (minus) log-likelihoods or
prediction errors for glmpath.
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, ...)
matrix of features
response
a list consisting of x:
a matrix of features and y:
response. data
is not needed if above x
and y
are input separately.
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.
an optional vector of weights for observations
an optional vector of offset. If a column of x
is used as
offset, the corresponding column must be excluded from x.
number of folds to be used in cross-validation. Default is
nfold=10.
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).
If type=loglik,
cross-validated minus log-likelihoods are
computed. If type=response,
cross-validated prediction errors
are computed. Default is loglik.
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.
If TRUE,
CV curve is plotted.
If TRUE,
standard errors are plotted.
other options for glmpath
Mee Young Park and Trevor Hastie (2007) L1 regularization path algorithm for generalized linear models. J. R. Statist. Soc. B, 69, 659-677.
glmpath, plot.glmpath, predict.glmpath
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab