First of all, thank you very much for your interest and time. My question (using R): To predict the yvar, I have run a lasso regression which reduced the set of xvariables from 736 to 30.
lasso.mod =glmnet(x,y,alpha=1)
cv.out =cv.glmnet (x,y,alpha=1)
lasso.bestlam =cv.out$lambda.min
tmp_coef = coef(cv.out,s=lasso.bestlam)
varnames = data.frame(name = tmp_coef@Dimnames[[1]][tmp_coef@i])
mylist = list(name = tmp_coef@Dimnames[[1]][tmp_coef@i])
Hence, I have the remaining variable names as a data frame and also as a list. How is it possible to create a new data frame which has these remaining 30 variables and their observations in it? In other words: How can I get a subset of my original data which does not contain 737 variables but only 31?
I think this should be quite easy, however I have been spending more than two hours and it never worked...
Best wishes, Thomas