title: Time-Series prediction in R caret package
body: <p>I'm trying to predict future return using the <code>caret</code> package.</p>
  
  <p>I know how to validate my model through <a href="https://i.stack.imgur.com/sFKL8.png" rel="nofollow noreferrer">Time-series cross validation</a>
  but I don't know how to get the latest prediction value.
  As you can see in this picture,</p>
  
  <p><a href="https://i.stack.imgur.com/sFKL8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sFKL8.png" alt="enter image description here"></a></p>
  
  <p>last value is always used as "horizon"
  I want to use this value as training data and get the last prediction even though I can't validate it anymore.
  Should I use predict function? or Are there other good ways?</p>
  
  <p>Here is my codes for building model and time-series validation.</p>
  
  <pre><code>timecontrol &lt;- trainControl(method = 'timeslice', initialWindow = window_length, horizon =4, selectionFunction = "best", 
                          returnResamp = 'final', fixedWindow = TRUE, savePredictions = 'final') 
  
  
  cur_val_m &lt;- train(test_sample[,-1], test_sample[,1], method = "knn", 
                        trControl = timecontrol, tuneGrid = "knnGrid")
  </code></pre>