我正在尝试使用 glmnet 拟合泊松模型,但我似乎无法正确获取正确形式的数据。所有变量都是分类的。这是处理几乎相同问题的较早问题,但给出的解决方案对我没有帮助 -as.matrix()
只是model.matrix
抛出了更多错误消息。
因为as.matrix
这就是我得到的:
x<-as.matrix(ld2)
> res<-glmnet(x,y,family = "poisson")
Error in fishnet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, :
NA/NaN/Inf in foreign function call (arg 4)
In addition: Warning message:
In fishnet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, :
NAs introduced by coercion
有任何想法吗?