Skip to contents

This function runs a glmnet() with ridge regression and pulls the best the beta value of the glmnet.fit object with value of lambda that gives minimum cvm.

Usage

ridgeCVmin(y, x, folds = 10)

Arguments

y

Required. response variable. Quantitative for family="gaussian", or family="poisson" (non-negative counts). For family="binomial" should be either a factor with two levels, or a two-column matrix of counts or proportions (the second column is treated as the target class; for a factor, the last level in alphabetical order is the target class). For family="multinomial", can be a nc>=2 level factor, or a matrix with nc columns of counts or proportions. For either "binomial" or "multinomial", if y is presented as a vector, it will be coerced into a factor. For family="cox", preferably a Surv object from the survival package: see Details section for more information. For family="mgaussian", y is a matrix of quantitative responses.

x

Required. An input matrix, of dimension nobs x nvars; each row is an observation vector. Can be in sparse matrix format (inherit from class "sparseMatrix" as in package Matrix)

folds

Optional. The number of cross validation folds to partition the data into. (Default = 10)

Value

The beta value of the glmnet.fit object with value of lambda that gives minimum cvm