title: "gam" model of caret not returning fitted.values
body: <p>I am using the <code>gam</code> model in <code>caret.train</code> (<code>caret</code> uses <code>gam</code> from package <code>mgcv</code>):</p>
  
  <pre><code>&gt; fit &lt;- train(P~II+TH+DR+TT,data=training,method="gam",trControl=ctrl,metric="Rsquared",preProc=c("center","scale"))
  &gt; names(fit)
   [1] "method"       "modelType"    "results"      "pred"         "bestTune"     "call"        
   [7] "dots"         "metric"       "control"      "finalModel"   "preProcess"   "trainingData"
   [13] "resample"     "resampledCM"  "perfNames"    "maximize"     "yLimits"      "times"       
   [19] "terms"        "coefnames"    "xlevels" 
  </code></pre>
  
  <p>I don't see <code>fitted.values</code> above, but a <code>gam</code> object should return <code>fitted.values</code> - <a href="http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/gam/html/gam.html" rel="nofollow">http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/gam/html/gam.html</a>
  As a result, I am not able to plot fitted vs residuals, and some other functions are also failing. A workaround is using <code>gam</code> directly instead of <code>caret</code>, but I plan on using other models too, and want a consistent interface.</p>
  
  <p>Please advise.</p>
  
  <p>EDIT: </p>
  
  <ol>
  <li><p>Data snapshot - <code>dput(head(training))</code> output:</p>
  
  <pre><code>structure(list(TT = c(1.810376, 0.089206, 0.623906, 0.676775, 
  0.206524, 1.014849), P = c(682L, 674L, 681L, 679L, 655L, 682L
  ), II = c(846000000L, 4790000L, 38600000L, 40600000L, 1379632L, 
  7526080L), WSM = c(5272L, 144L, 576L, 576L, 2336L, 18696L), TSM = c(168704L, 
  4608L, 18432L, 18432L, 74752L, 598272L), L2M = c(1.49e+09, 12600000, 
  85700000, 1.24e+08, 4214560, 33560200), DR = c(2.52e+09, 18400000, 
  1.3e+08, 1.8e+08, 5559030, 44681000), DW = c(11600000L, 5440000L, 
  39600000L, 46400000L, 4920550L, 36812430L), TH = c(32.032843125, 
  0.1880727305, 0.2003506939, 0.1983195715, 0.558498625, 0.495952125
  )), .Names = c("TT", "P", "II", "WSM", "TSM", "L2M", "DR", "DW", 
  "TH"), row.names = c(3L, 5L, 7L, 8L, 9L, 10L), class = "data.frame")
  </code></pre></li>
  <li><p><code>str(fit)</code> shows <code>fitted.values</code> inside <code>finalModel</code> as suggested by @nograpes.</p>
  
  <pre><code>$ finalModel  :List of 50
  ..$ coefficients     : Named num [1:37] 761 -1839 -377 745 -473 ...
  .. ..- attr(*, "names")= chr [1:37] "(Intercept)" "s(II).1" "s(II).2" "s(II).3" ...
  ..$ residuals        : num [1:44] -8.229 0.402 -11.41 -26.357 -8.202 ...
  ..$ fitted.values    : Named num [1:44] 690 674 683 707 687 ...
  </code></pre></li>
  </ol>