Learn R Programming

AdapEnetClass (version 1.2)

cv.AWEnet: Computes K-fold cross validated error curve for AEnet and WEnet

Description

This function computes the K-fold cross validation estimates.

Usage

cv.AWEnet(X, Y, delta, weight, lambda2, maxit, K = 10, fraction = seq(from = 0, to = 1, length = 100), plot.it = F, se = TRUE, AEnet = T, all.folds = NULL)

Arguments

X
covariate matrix under study, particularly for AFT modelling. The order of matrix covariate is typically n by p.
Y
typically the logarithmic of the survival time under AFT models. Otherwise survival time.
delta
status. it includes value 1 for uncensored and value 0 for censored subject.
weight
vector of observation weights. Weight is based on initial estimator that is obtained from elastic net on the weighted data (see Enet.wls function) or from Gehan estimator (see mrbj function).
lambda2
regularization parameter for the L2 norm of the coefficients. This is typically assumed to take values in a relatively small grid.
maxit
an optional bound for the number of steps to be taken. Default is 10.
K
number of folds.
fraction
abscissa values at which CV curve should be computed. This is the fraction of the saturated |beta|. The default value is seq(from = 0, to = 1, length =100).
plot.it
if T then plot will be showed. Default is T.
se
include standard error bands.
AEnet
if T then the results are based on adaptive elastic net otherwise based on weighted elastic net.
all.folds
null.

Value

lambda2
as AEnetCC.aft
cv
the CV curve at each value of index
cv.mse
the mean square error of the CV curve
cv.error
the standard error of the CV curve

Details

This function computes the K-fold cross validation, cross validation error, cross validation mean squared error.

References

Khan and Shaw (2015) imputeYn: Imputing the last largest censored observation/observations under weighted least squares. R package version 1.3, https://cran.r-project.org/package=imputeYn.

Khan and Shaw (2015). Variable Selection for Survival Data with a Class of Adaptive Elastic Net Techniques. Statistics and Computing (published online; DOI: 10.1007/s11222-015-9555-8). Also available in http://arxiv.org/abs/1312.2079.

See Also

cv.AWEnetCC

Examples

Run this code
#For full data typically used for AFT models (using imputeYn (2015) package).
dat<-data(n=100, p=10, r=0, b1=c(rep(5,5),rep(0,5)), sig=1, Cper=0)

#This needs to run for generating weights of the observations
l<-mrbj(cbind(dat$y, dat$delta) ~ dat$x, mcsize=100, trace=FALSE, gehanonly=FALSE)

#cv.AWEnet: Cross validation of Adaptive elastic net
wt<-l$enet
## Not run: cv1 <-cv.AWEnet(dat$x, dat$y, dat$delta, weight=wt, lambda2=0.001, maxit=10,
# plot.it = T, AEnet=T)## End(Not run)
## Not run: cv1$index[which.min(cv1$cv)]

#cv.AWEnet: Cross validation of weighted elastic net
## Not run: l<-mrbj(cbind(dat$y, dat$delta) ~ dat$x, mcsize=100, trace=FALSE, gehanonly=TRUE)
## Not run: wt<-l$gehansd
## Not run: cv2 <-cv.AWEnet(dat$x, dat$y, dat$delta, weight=wt, lambda2=0.001, 
# maxit=10, plot.it = T, AEnet=F)## End(Not run)
## Not run: cv2$index[which.min(cv2$cv)]

Run the code above in your browser using DataLab