k_choose1: Selecting the optimal ridge regression parameters by GCV

Description Usage Arguments Value Examples

View source: R/k_choose.R

Description

Selecting the optimal ridge regression parameters by GCV

Usage

1
k_choose1(X, Y, kmax, N)

Arguments

X

the independent variable

Y

the response variable

kmax

the maximum value of the ridge regression parameter

N

the number of cross validation

Value

the optimal ridge regression parameter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
library(MASS)
data <- read.table("E:/Rcpp/data.txt", header = TRUE)
x <- as.matrix(data[,2:21])
y <- data[,1]
k_best1 <- k_choose1(x, y, kmax = 2, N = 2000)
print(k_best1)
 #compare with the optimal parameter gotten by existing ridge package 
select(lm.ridge(y~x, data = data, lambda = seq(0,2,0.001)))
## End(Not run)

SC19037/SC19037 documentation built on Jan. 3, 2020, 1:08 p.m.