cv_grid_ridge: Computes cross-validated solution for ridge regression

Description Usage Arguments Value Examples

View source: R/cv_grid_ridge.R

Description

Cross-validation wrapper for grid_ridge that computes solutions, selects and fits the optimal model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cv_grid_ridge(
  x,
  y,
  K = 5,
  var_order = NULL,
  lambda = NULL,
  nlambda = 100L,
  lambda.min.ratio = ifelse(n < p, 0.01, 1e-04),
  grid.size = p,
  lambda.mult = 1e+05,
  fold_assign = NULL
)

Arguments

x

Design matrix, n x p.

y

Vector of responses, length n.

K

Number of folds for cross-validation. Must be at least 2

var_order

For user-specified ordering of variables. Indices start at 0, start with least important variable and end with most. By default order will be induced from scaling of columns in design matrix

lambda

For user-specified sequence of tuning parameter lambda

nlambda

Length of automatically generated sequence of tuning parameters lambda

lambda.min.ratio

Ratio of max/min lambda for automatically generated sequence of tuning parameters lambda

grid.size

Number of subsets of variables for which a solution path will be computed for

lambda.mult

Scales the sequence of lambda by a constant

fold_assign

For user-specified vector of assignment of folds for cross-validation. Must be of the form of integer vector with entries in 1 , ... , K.

Value

A list of objects:

Examples

1
2
3
4
5
6
7
8
set.seed(1)
X = matrix(0, 50, 100)
betavec = c(rep(1,5),rep(0,95))
X[ , 1:5 ] = matrix(rnorm(250), 50, 5)
Y = as.vector(X %*% betavec)
Y = Y + rnorm(50)
X = X + matrix(rnorm(50*100), 50, 100)
mod1 = cv_grid_ridge(X, Y, grid.size = 50)

bgs25/SubsetGridRegression documentation built on Dec. 19, 2021, 8:50 a.m.