glmnet, error in loop$lambda and Fortran code (error code -2)

When using these lines of code:

Res_F <- K1Z1vK2K3ROI1_Spec

  index <- createDataPartition(y=Res_F$Var,p=0.5,list=FALSE)
  train2 <- dplyr::select(Res_F, corr, rdist, CCF2,Wcorr, Wcorr2, Wcorr3, Var) 
  train <- train2[index,]
  test <-  train2[-index,]
  MySummary  <- function(data, lev = NULL, model = NULL){
    a1 <- defaultSummary(data, lev, model)
    b1 <- twoClassSummary(data, lev, model)
    c1 <- prSummary(data, lev, model)
    out <- c(a1, b1, c1)
  classCtrl <- trainControl(method = "repeatedcv", number=10,repeats=5,classProbs =  TRUE,summaryFunction = MySummary,savePredictions = "final")
  model <- train(Var~., train, method= "glmnet", metric= "Spec",  trControl=classCtrl)

I get the following error:

Error in loop$lambda[loop$alpha == alph[i]] <- np[which.max(np)] : 
  replacement has length zero
In addition: Warning message:
from glmnet Fortran code (error code -2); Convergence for 2th lambda value not reached after maxit=100000 iterations; solutions for larger lambdas returned

Here is a link to a txt files of the dataframe K1Z1vK2K3ROI1_Spec:

in my research I have dozens of dataframes like this one that are all computed in the same way at first and I never had any error. However with this one, it does not work.

Here is a link to the txt file of a dataframe that works, K2Z1vK1K3ROI1_Spec:

If you copy and paste the content of the linked txt files into Rstudio you should directly get the dataframes in your environment (645 observations of 11 variables)

Does anyone know where it comes from and how I can get rid of it ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.