cv.bridge {rbridge}R Documentation

Cross-validation for bridge

Description

Does k-fold cross-validation for bridge, produces a plot, and returns a value for lambda

Usage

cv.bridge(X, y, q, lambda, nfolds = 10, lambda.min = ifelse(n > p,
  0.001, 0.05), nlambda = 100, eta = 1e-07, converge = 10^10,
  num_threads = 10)

Arguments

X

X matrix as in bridge.

y

response y as in bridge.

q

is the degree of norm which includes ridge regression with q=2 and lasso estimates with q=1 as special cases

lambda

lambda sequence; default is NULL. It is given by user or cv.rbridge chooses its own sequence.

nfolds

number of folds - default is 10.

lambda.min

The smallest value for lambda if n>p is 0.001 and 0.05 otherwise.

nlambda

The number of lambda values - default is 100

eta

is a preselected small positive threshold value. It is deleted jth variable to make the algorithm stable and also is excluded jth variable from the final model. Default is 1e-07.

converge

is the value of converge. Defaults is 10^10. In each iteration, it is calculated by sum of square the change in linear predictor for each coefficient. The algorithm iterates until converge > eta.

num_threads

Number of threads used for parallel computation over the folds,

Details

Computes bridge

Value

An object of class rbridge, a list with entries

cve

the mean cross-validated error.

cvse

estimate of standard error of cvm.

cvup

upper curve = cvm+cvsd.

cvlo

lower curve = cvm-cvsd.

lambda

the values of lambda used in the fits

nz

number of non-zero coefficients at each lambda.

betas

estimated coefficient at each lambda.

lambda.min

value of lambda that gives minimum cve

lambda.1se

largest value of lambda such that error is within 1 standard error of the minimum

Author(s)

Bahadir Yuzbasi, Mohammad Arashi and Fikri Akdeniz
Maintainer: Bahadir Yuzbasi b.yzb@hotmail.com

See Also

bridge

Examples

set.seed(2019) 
beta <- c(3, 1.5, 0, 0, 2, 0, 0, 0)
p <- length(beta)
beta <- matrix(beta, nrow = p, ncol = 1)

n = 100
X = matrix(rnorm(n*p),n,p)
y = X%*%beta + rnorm(n) 

######## Model 1 
model1 <- cv.bridge(X, y, q = 1)
print(model1)
coef(model1,s='lambda.min')
predict(model1,newx=X[1:5,], s="lambda.min", type="response")
predict(model1, s="lambda.min",type="coefficient")

######## Model 2 
model2 <- cv.bridge(X, y, q = 2)
print(model2)
coef(model2,s='lambda.min')
predict(model2,newx=X[1:5,], s="lambda.min", type="response")
predict(model2, s="lambda.min",type="coefficient")


[Package rbridge version 1.0.2 Index]