Commit c3554e31 authored by Tom Reynkens's avatar Tom Reynkens

Move check after possible standardization

parent 0d6b05ea
......@@ -200,18 +200,20 @@
X.train <- X[cv.fold.allocation != k, ]
weights.train <- weights[cv.fold.allocation != k]
offset.train <- offset[cv.fold.allocation != k]
# Check if all levels are present in cross-validation training sample
if (any(colSums(abs(X.train)) < 1e-14 & colSums(abs(X)) > 1e-14)) {
stop(paste0("Some levels are missing in cross-validation sample ", k, ".",
" Please use a different (larger) value for 'k' in the control object."))
}
# Standardize X.train matrix for predictors with Lasso or Group Lasso penalty (if standardize = TRUE)
list.stand <- .X.stand(X = X.train, standardize = attr(X, "standardize"), ind.stand = ind.stand,
n.par.cov = n.par.cov, weights = weights.train)
# Possibly standardized X.train matrix
X.train <- list.stand$X
# Check if all levels are present in cross-validation training sample
if (any(colSums(abs(X.train)) < 1e-14 & colSums(abs(X)) > 1e-14)) {
stop(paste0("Some levels are missing in cross-validation sample ", k, ".",
" Please use a different (larger) value for 'k' in the control object."))
}
# Set attributes (about standardization)
attr(X.train, "standardize") <- attr(X, "standardize")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment