vboot: Generic function for bootstrap validation

Description Usage Arguments References Examples

View source: R/parallel_vboot.R

Description

Validate 'glmnet' linear, logistic or cox regression using bootstrap.

Usage

1
2
vboot(fit, x, y, s, nfolds = 5, B = 200, cv_replicates = 100,
  lambda = TRUE, n_cores = max(1, parallel::detectCores() - 1))

Arguments

fit

Object from glmnet fit.

x

A matrix of the predictors, each row is an observation vector.

y

A vector of response variable. It should be quantitative for lineal regression, a factor with two levels for logistic regression, a factor with more than two levels for multinomial regression or a two-column matrix with columns named 'time' and 'status' for cox regression.

s

Value of the penalty parameter "lambda" selected from the original 'cv.glmnet'.

nfolds

Number of folds for cross validation as in 'cv.glmnet'.

B

Number of bootsrap samples.

cv_replicates

Number of replicates for the cross-validation step.

lambda

By default, the validation is adjusted using 'lambda.1se' which has error within 1 standard error of the best model. If 'FALSE' the 'lambda.min' referered to the lowest CV error will be used.

n_cores

number of cores to use in parallel. Default detectCores()-1.

References

Jerome Friedman, Trevor Hastie, Robert Tibshirani (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1-22. URL http://www.jstatsoft.org/v33/i01/.

Noah Simon, Jerome Friedman, Trevor Hastie, Rob Tibshirani (2011). Regularization Paths for Cox's Proportional Hazards Model via Coordinate Descent. Journal of Statistical Software, 39(5), 1-13. URL http://www.jstatsoft.org/v39/i05/.

Harrell Jr, F. E. (2015). Regression modeling strategies: with applications to linear models, logistic and ordinal regression, and survival analysis. Springer.

Gordon C.S. Smith, Shaun R. Seaman, Angela M. Wood, Patrick Royston, Ian R. White (2014). Correcting for Optimistic Prediction in Small Data Sets, American Journal of Epidemiology, Volume 180, Issue 3, 1 August 2014, Pages 318-324, https://doi.org/10.1093/aje/kwu140

Examples

1
2
3
4
5
6
7
8
# Create the data
set.seed(25)
x <- matrix(rnorm(80),ncol=4)
y <- x[,4]*0.8+x[,3]*0.4+rnorm(20)
# Fit glmnet model
fit_enet <- glmnet::glmnet(x, y, alpha = 0.5)
# Bootstrap validation
vboot(fit_enet, x, y, nfolds = 3, B = 2, s = 0.5, cv_replicates = 5, n_cores = 1)

BootValidation documentation built on May 1, 2019, 8:24 p.m.