data("wheat")
X <- wheat$x
y <- wheat$protein
n <- nrow(wheat$x)
set.seed(1001)
samp.idx <- sample(1L:n, round(n * 0.7))
X.cal <- X[samp.idx, ]
y.cal <- y[samp.idx]
X.test <- X[-samp.idx, ]
y.test <- y[-samp.idx]
# This could run for a while
if (FALSE) {
cv.fit <- cv.OHPL(
x, y,
maxcomp = 6, gamma = seq(0.1, 0.9, 0.1),
x.test, y.test, cv.folds = 5, G = 30, type = "max"
)
# the optimal G and gamma
cv.fit$opt.G
cv.fit$opt.gamma
}
Run the code above in your browser using DataLab