简体   繁体   English

R中的cv.lars错误

[英]Error in cv.lars in R

I have a question regarding the cv.lars . 我有关于cv.lars的问题。 Bellow there is a description for the data I use: 贝娄有一个我使用的数据的描述:

is.numeric(Y$Y1)
[1] TRUE

length(Y$Y1)
[1] 589


dim(Training_XX[7:ncol(Training_XX)])
[1]  589 5677

I have already run lasso using lars package. 我已经使用lars包运行套索了 My code is as follows: 我的代码如下:

LASSO_1<-lars(as.matrix(X[7:ncol(X)]), 
              Y$Y1,type=c("lasso"), 
              normalize=TRUE, use.Gram=FALSE).

The above procedure seems to run fine. 上述程序似乎运行良好。 However, when I'm trying to cross-validate for the lambda value, I get the following error: 但是,当我尝试交叉验证 lambda值时,我收到以下错误:

Error in if (zmin < gamhat) { : missing value where TRUE/FALSE needed

My code for the cross-validation is: 我的交叉验证代码是:

CV<-cv.lars(as.matrix(X[7:ncol(X)]),Y$Y1,use.Gram=FALSE,max.steps=500)
lambda_Y1=CV$index[which.min(CV$cv)]

Does anyone has any idea what's going on? 有谁知道发生了什么事? I really don't know what that error means and what's wrong with my data (and or code). 我真的不知道这个错误意味着什么,我的数据(和/或代码)有什么问题。

I got the same error, and the problem (at least in my case) was that two columns of my data matrix were equal. 我得到了同样的错误,问题(至少在我的情况下)是我的数据矩阵的两列是相等的。 It seems lars doesn't handle this well. 似乎lars不能很好地处理这个问题。 Just filter columns with very high correlation. 只需过滤具有非常高相关性的列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM