I am doing a loop.
all_datasets[["X19"]]
[1] 2.000000e+00 0.000000e+00 0.000000e+00 1.700000e+01 0.000000e+00 2.300000e+01 1.100000e+01 1.470314e+51 0.000000e+00
[10] 0.000000e+00 7.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 1.830000e+02 0.000000e+00 1.324677e+11 1.000000e+00
[19] 1.200000e+01 0.000000e+00 0.000000e+00 1.000000e+01 1.300000e+01 0.000000e+00 1.000000e+00
min_column_data
[1] 5 10 7 10 11 11 4 12 17 4 14 6 6 3 3 9 2 11 7 5 5 14 2 5 8
cv <- cv.glmnet(x = cbind(0, as.matrix(min_column_data)), y = all_datasets[["X19"]],
family = poisson(link = "log"), type.measure = "mse", alpha = 1, nlambda = 100, nfolds = 5)
Error: inner loop 1; cannot correct step size
In addition: Warning messages:
1: Convergence for 1th lambda value not reached after maxit=1e+05 iterations; solutions for larger lambdas returned
2: Infinite objective function!
3: step size truncated due to divergence
Basically, I am doing a loop. So this time is X19, next time is X20,.., etc. But sometimes I cannot can get a desired cv.glmnet.
So my first question is the above, how to fix the code. My second question is when I have such error and warning by R, what does that mean? Because my next step is to use Lasso to fit the model and get the coefficients.
Fit the model
fit <- glmnet(x = cbind(0, as.matrix(min_column_data)), y = all_datasets[[j]],
family = poisson(link = "log"), lambda = cv$lambda.min)
If it means my coefficients are 0, then it is perfect. Because this should be 0, i.e., X19 doesn't have any relationship with the min_column_data.