hierNet (version 1.9)

hierNet.cv: Cross-validation function for hierNet

Description

Uses cross-validation to estimate the regularization parameter for hierNet

Usage

hierNet.cv(fit, x, y, nfolds=10,folds=NULL,trace=0)

Arguments

fit

Object returned from call to hierNet.path or hierNet.logistic.path. All parameter settings will be taken from this object.

x

A matrix of predictors, where the rows are the samples and the columns are the predictors

y

A vector of observations, where length(y) equals nrow(x)

nfolds

Number of cross-validation folds

folds

(Optional) user-supplied cross-validation folds. If provided, nfolds is ignored.

trace

Verbose output? 0=no, 1=yes

Value

lamlist

Vector of lambda values tried

cv.err

Estimate of cross-validation error

cv.se

Estimated standard error of cross-validation estimate

lamhat

lambda value minimizing cv.err

lamhat.1se

largest lambda value with cv.err less than or equal to min(cv.err)+ SE

folds

Indices of folds used in cross-validation

yhat

n by nlam matrix of predicted values. Here, ith prediction is based on training on all folds that do not include the ith data point.

nonzero

Vector giving number of non-zero coefficients for each lambda value

call

The call to hierNet.cv

References

Bien, J., Taylor, J., Tibshirani, R., (2013) "A Lasso for Hierarchical Interactions." Annals of Statistics. 41(3). 1111-1141.

See Also

hierNet,hierNet.path, hierNet.logistic,hierNet.logistic.path

Examples

Run this code
# NOT RUN {
set.seed(12)
x=matrix(rnorm(100*10),ncol=10)
x=scale(x,TRUE,TRUE)
y=x[,1]+2*x[,2]+ x[,1]*x[,2]+3*rnorm(100)
fit=hierNet.path(x,y)
fitcv=hierNet.cv(fit,x,y)
print(fitcv)
plot(fitcv)


x=matrix(rnorm(100*10),ncol=10)
x=scale(x,TRUE,TRUE)
y=x[,1]+2*x[,2]+ x[,1]*x[,2]+3*rnorm(100)
y=1*(y>0)
fit=hierNet.logistic.path(x,y)
fitcv=hierNet.cv(fit,x,y)
print(fitcv)
plot(fitcv)
# }

Run the code above in your browser using DataLab