cv.sparsenet {sparsenet} | R Documentation |
Cross-validation for sparsenet
Description
Does k-fold cross-validation for sparsenet, produces a plot,
and returns values for gamma, lambda
Usage
cv.sparsenet(x, y, weights, type.measure = c("mse", "mae"), ...,nfolds = 10,
foldid, keep=FALSE, trace.it=FALSE)
Arguments
x |
|
y |
response |
weights |
Observation weights; defaults to 1 per observation |
type.measure |
loss to use for cross-validation. Currently two
options:
squared-error ( |
... |
Other arguments that can be passed to |
nfolds |
number of folds - default is 10. Although |
foldid |
an optional vector of values between 1 and |
keep |
If |
trace.it |
If |
Details
The function runs sparsenet
nfolds
+1 times; the
first to get the lambda
sequence, and then the remainder to
compute the fit with each of the folds omitted. The error is
accumulated, and the average error and standard deviation over the
folds is computed.
Value
an object of class "cv.sparsenet"
is returned, which is a
list with the ingredients of the cross-validation fit.
lambda |
the values of |
cvm |
The mean cross-validated error - a matrix shaped like lambda |
cvsd |
estimate of standard error of |
cvup |
upper curve = |
cvlo |
lower curve = |
nzero |
number of non-zero coefficients at each |
name |
a text string indicating type of measure (for plotting purposes). |
sparsenet.fit |
a fitted sparsenet object for the full data. |
call |
The call that produced this object |
parms.min |
values of |
which.min |
indices for the above |
lambda.1se |
|
which.1se |
indices of the above |
Author(s)
Rahul Mazumder, Jerome Friedman and Trevor Hastie
Maintainer: Trevor Hastie <hastie@stanford.edu>
References
Mazumder, Rahul, Friedman, Jerome and Hastie, Trevor (2011) SparseNet: Coordinate Descent with Nonconvex Penalties. JASA, Vol 106(495), 1125-38, https://hastie.su.domains/public/Papers/Sparsenet/Mazumder-SparseNetCoordinateDescent-2011.pdf
See Also
glmnet
package, predict
, coef
, print
and plot
methods, and the sparsenet
function.
Examples
train.data=gendata(100,1000,nonzero=30,rho=0.3,snr=3)
fit=sparsenet(train.data$x,train.data$y)
par(mfrow=c(3,3))
plot(fit)
par(mfrow=c(1,1))
fitcv=cv.sparsenet(train.data$x,train.data$y,trace.it=TRUE)
plot(fitcv)