Linda,

Thanks for the example.

I did this to make it more reproducible:

  set.seed(1)
  X<-matrix(rnorm(50*100),nrow=50)
  y<-rnorm(50*1)

  dimnames(X)

  colnames(X) <- paste("V", 1:nrow(X))

  # Applying caret package

  set.seed(2)
  con<-trainControl(method="cv",number=10)

  data<-NULL
  data<- train(X,y, "lasso", metric="RMSE",tuneLength = 10, trControl = con)

I see your point here, but this code gives the same results:

  fit2 <- enet(X, y, lambda = 0)
  predict(fit2, mode = "fraction", s = data$bestTune$.fraction, type =
"coefficient")$coef

(at least train() names the predictors).

To me, it looks like enet is doing some filtering:

   > dim(X)
   [1]  50 100
   > length(fit2$meanx)
   [1] 56

This appears to be independent of caret. I would contact the package
maintainer off-list and ask.

Max

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to