简体   繁体   English

cv.glmnet出错

[英]Error in cv.glmnet

I am using the following code getting the error message in R version 2.13.1. 我使用以下代码获取R版本2.13.1中的错误消息。 in mac. 在mac。

cv.glmnet(dsgn.mat,resp,family="gaussian",nfolds=5)

Error in as.matrix(cbind2(1, newx) %*% nbeta) : 
error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Error in t(.Call(Csparse_dense_crossprod, y, t(x))) : 
error in evaluating the argument 'x' in selecting a method for function 't': Error: invalid class 'NA' to dup_mMatrix_as_dgeMatrix

I should mention that there is no message if I use only glmnet then it is working fine. 我应该提一下,如果我只使用glmnet就没有消息那么它工作正常。

Without any example data, all I can say is that, generally, most errors that pop up only during cross validation are because one of the random folds ends up "bad". 没有任何示例数据,我只能说,通常, 只有在交叉验证期间弹出的大多数错误都是因为其中一个随机折叠最终“坏”。 This is obviously more common if you don't have many observations in your data set. 如果您在数据集中没有太多观察结果,这显然更常见。 For example, do you have any NAs in your data (might lead to an entire fold of NAs)? 例如,您的数据中是否有任何NA(可能导致整个NAs)?

You can get around this by preprocessing your data, but glmnet also will let you directly prescribe the folds via parameter foldid . 您可以通过预处理数据来解决这个问题,但glmnet也可以通过参数foldid直接指定折叠。

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

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