LASSO error Error in elnet

This is my code :
#Import libraries
library(ISLR)
library(glmnet)
library(dplyr)
library(tidyr)

#load data
mydata <- read.csv("data_lasso.csv")
options(max.print=999999)

#Data type flatten & extraction
y = mydata[,1]
x = mydata[,2:551]
y = as.numeric(unlist(y))
x = as.numeric(unlist(x))
x <- matrix(x, nrow = 3373, byrow = FALSE)

#Trace plot for LASSO
lasso_model = glmnet(x,y,alpha=1,lambda=c(0.0000000001,0.000000001,0.00000001,0.0000001,0.000001,0.00001,0.0001,0.001,0.01,0.1,1))
plot(lasso_model)

#2 Outputs in Excel
lasso_model = glmnet(x,y,alpha=1,lambda=c(0.1,0.05,0.01,0.005,0.001))
coef(lasso_model)
regression_model= glm(mydata$e_hat~.,data=mydata)
summary(regression_model)

This is error :slight_smile:

lasso_model = glmnet(x,y,alpha=1,lambda=c(0.0000000001,0.000000001,0.00000001,0.0000001,0.000001,0.00001,0.0001,0.001,0.01,0.1,1))
Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, :
NA/NaN/Inf in foreign function call (arg 5)

lasso_model = glmnet(x,y,alpha=1,lambda=c(0.1,0.05,0.01,0.005,0.001))
Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian, :
NA/NaN/Inf in foreign function call (arg 5)

Could you please tell me why ? Thanks

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.