cv.glmnet Function

Dear All,

I'm a new user for R studio and I hope you can support me with this issue.
I would liket to us cv.glmnet function but first it always give me error message.
Here code that I wrote:
attach(LA10061)
set.seed(2)
sample<-sample.split(LA10061,SplitRatio = 0.7)
train<-subset(LA10061,sample="TRUE")
test<-subset(LA10061, sample="FALSE")
y_train<-train[ ,1]
x_train<-train[ ,2:15]
y_test<-test[ ,1]
x_test<-test[ ,2:15]
x_train1<-as.matrix(x_train)
x_train2<-model.matrix(~x_train1)
y_train1<- as.matrix(y_train)

alpha0.fit<-cv.glmnet(x_train,y_train,type.measure="mse",alpha=0,family="gaussian")

First error message was:
Error in storage.mode(y) <- "double" :
'list' object cannot be coerced to type 'double'
after some research I realize i need to convert in matrix my data but then I get this error message:
Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian,
and I realize the solution is use function model.matrix but then I get this error message:
Error in [[<-.data.frame(*tmp*, i, value = c(36L, 32L, 145L, 64L,

I'm a bit lost about how to solve this issue.
Ciao
Anna

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