我遇到了 glmnet 的问题,因为我不断收到错误消息
"Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : NA/NaN/Inf in foreign function call (arg 5)
In addition: Warning message:
In elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, : NAs introduced by coercion"
下面我可以使用“iris”数据集复制错误,但这里是我的特定数据的简化代码:
vars <- as.matrix(ind.vars)
lasso <- glmnet(vars, y=cup98$TARGET_D, alpha=1)
这是您可以轻松复制的内容:
data(iris)
attach(iris)
x <- as.matrix(data.frame(Sepal.Width, Petal.Length, Petal.Width, Species))
y <- Sepal.Length
lasso <- glmnet(x,y=y, alpha=1)
非常感谢大家!