Closed qianchd closed 1 year ago
Thanks for your valuable feedback, and I'm pleased to incorporate one of your suggestions into the program.
abess
prioritizes using column names rather than positions for identification so that duplicated names will cause confusion. We plan to add the following checks to avoid this situation:
if (length(unique(para$vn)) != length(para$vn)) {
stop("The colnames of x are duplicated!")
}
Once again, thank you for your assistance.
Describe the bug
In some extreme case, the colnames can be duplicated. For example colnames=("", "", "", "") or ("X", "X", "X", "X"). It makes the function
predict.abess
fail when it tries to runnewx <- newx[, vn]
. However the main fitting functionabess::abess
still pass.Code for Reproduction
A clear and concise description of what you expected to happen.
The colnames of
X
need to be checked in the abess::abess function. If the colnames are duplicated, either a error should be raised or the matrixX
should be treated as the unamed matrix (colnames(X) == NULL
). Alternative choice is to check if the rownames setrownames(object[["beta"]])
is a subset of the colnames ofnewx
which improves the lineif (!is.null(colnames(newx)))
in thepredict.abess
function.