title: Retrieve coefficients from R's train function in caret using forward regression and/or LARS
body: <p>I’m working in R and exploring the use of caret for variable selection and weighting using several methods. Here I’m exploring using forward stepwise and least angular regression (LARS), using tuning parameters for each. In the code below, I’ve arbitrarily chosen a dependent variable (y) and a subset of predictors (x’s) and have ran them via training algorithms using a subset of 70% of the data. To do so, I’m applying repeated 10-fold cross validations.
  What I’m struggling with is locating a command to identify the final model parameters (e.g., intercept, beta weights) derived from the train function. I’m not readily seeing it when I call object$finalModel. Is there a way to recover these in R using the methods listed (forward stepwise regression and LARS)? I feel like this would have to exist....</p>
  
  <p>Thanks!</p>
  
  <pre><code>library (caret)
  library(AppliedPredictiveModeling)
  data(abalone)
  str(abalone)
  
  set.seed(18)
  inTrain &lt;- sample(1:(round(nrow(abalone)*.7)),replace=FALSE)
  
  train_df &lt;- abalone [inTrain,]
  test_df &lt;- abalone [-inTrain,]
  
  #predicting Diameter using several of the dataset's variables#
  train_df_x &lt;- train_df [,4:8]
  test_df_x &lt;- test_df [,4:8]
  y_train &lt;- train_df [,3]
  y_test &lt;- test_df  [,3]
  
  set.seed(18)
  fold.ids &lt;- createMultiFolds(y_train,k=10,times=3)
  fitControl &lt;- trainControl(method = "repeatedcv",
                             number = 10,
                             repeats = 3,
                             returnResamp = "final",
                             index = fold.ids,
                             summaryFunction = defaultSummary,
                             selectionFunction = "oneSE")
  
  ### Forward regression ###
  library(leaps)
  forwardLmGrid &lt;- expand.grid (.nvmax=seq(2,5))
  set.seed(18)
  F_OLS_fit &lt;- train(train_df_x, y_train,"leapForward",trControl = fitControl,metric="RMSE", tuneGrid=forwardLmGrid)
  
  ### LARS ###
  larGrid &lt;- expand.grid(.fraction=seq(.01,.99,length=50))
  library(lars)
  Lar_fit &lt;- train(train_df_x, y_train,"lars",trControl = fitControl,metric="RMSE", tuneGrid=larGrid)
  </code></pre>