I'm trying to fit a poisson model using glmnet, but I can't seem to get the data in the right form right. All the variables are categorical. The is an earlier question dealing with pretty much the same problem, but the solutions given didn't help me- as.matrix()
and model.matrix
just threw out more error messages.
For as.matrix
here's what I got:
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
Any ideas?