I would like to use GLM and Elastic Net to select those relevant features + build a linear regression model (i.e., both prediction and understanding, so it would be better to be left with relatively few parameters). The output is continuous. It's $20000$ genes per $50$ cases. I've been reading about the
glmnet package, but I'm not 100% sure about the steps to follow:
Perform CV to choose lambda:
cv <- cv.glmnet(x,y,alpha=0.5)
(Q1) given the input data, would you choose a different alpha value?
(Q2) do I need to do something else before build the model?
Fit the model:
(Q3) anything better than "covariance"?
(Q4) If lambda was chosen by CV, why does this step need
(Q5) is it better to use
Obtain the coefficients, to see which parameters have fallen out ("."):
In the help page there are many
predict.lognet, etc). But any "plain" predict as I saw on an example.
(Q6) Should I use
Despite what I've read about regularization methods, I'm quite new in R and in these statistical packages, so it's difficult to be sure if I'm adapting my problem to the code. Any suggestions will be welcomed.
Based on "As previously noted, an object of class train contains an element called
finalModel, which is the fitted model with the tuning parameter values selected by resampling. This object can be used in the traditional way to generate predictions for new samples, using that model's
caret to tune both alpha and lambda:
trc = trainControl(method=cv, number=10) fitM = train(x, y, trControl = trC, method="glmnet")
fitM replace previous step 2? If so, how to specify the glmnet options (
And the following
predict step, can I replace
If I do
trc = trainControl(method=cv, number=10) fitM = train(x, y, trControl = trC, method="glmnet") predict(fitM$finalModel, type="coefficients")
does it make sense at all or am I incorrectly mixing both package vocabulary?