Elastic net beta coefficients using Glmnet with Caret

In glmnet using caret my the model is trained and tuned by cross validation on my training set. I have a 10 fold cross validation, over a grid of 10 alphas and 10 lambdas. The best model chosen by glmnet is the model with the combination of alpha and lambda which has the best performance. This performance is an average over the 10 cross validation folds to reduce variance.

I then use the best model to predict outcome in unseen test data and compare the predictions against the actual test set outcome.

When I call up the best model's beta coefficients (see below) am I correct in my understanding that these coefficients are the average over the 10 cross validation folds?

coef(bestModel$finalModel, bestModel$bestTune\$lambda)

The training and test split is often repeated to reduce variance in calculated model performance metric. When one repeats the initial 70:30 training/test split several times in an outer loop, models with different combinations of lambda and alpha often chosen and with different beta coefficients. I know I can average the performance metric but can I also average these models beta coefficients? Given that such models commonly have different combinations of alpha and lambda.

• How exactly do you "call up the best model's beta coefficients"? – Richard Hardy Jun 21 '17 at 7:45
• amended question – samleighton87 Jun 21 '17 at 8:33
• The answer then depends on what bestModel is, I suppose. But perhaps Caret documentation has something about it? – Richard Hardy Jun 21 '17 at 9:10
• bestModel is the model chosen by cross validation from the grid of alpha and lambdas which has the best performance metric on the validation set. I'm just not sure how the coefficients are worked out - perhaps once the model is chosen it is refit on the entire test set. I'll try to clarify further. – samleighton87 Jun 21 '17 at 9:19
• yes, you are refitting the model with the lambda and alpha found by crossvalidation. You do not average across betas, you get the new ones. – rep_ho Jun 21 '17 at 9:28