Hyndman on cross-validation for time-seriesįirst, let me give you a scholarly article on the topic. Lastly, the 12-month horizon in this example is not a true multi-period forecasting as Hyndman does it in his examples. It merely trains a model to best explain the variation in unemployment (which also in this case is a stationary time-series creating all sorts of issues in modelling process) based on predictor variables at the same economic report dates. Next, this example is only descriptive statistics and not predictive (forecasting) because the data we want to forecast (unemploy) is not lagged correctly. Unemployment data may be two months behind the other indicators in terms of release date, which would then introduce a model bias in Shambho's example. In this case, the economics data set has aligned data at their economic reporting dates and not their release date, which is never the case in real live applications (economic data points have different time stamps). The problem with time-series data is that look-ahead bias is easy if one is not careful. So in order not to misguide future readers that want to use the caret package for predictive modelling on time-series (and here I do not mean autoregressive models), I want to highlight a few things. Shambho's answer provides decent example of how to use the caret package with TimeSlices, however, it can be misleading in terms of modelling technique. The final value used for the model was ncomp = 1. RMSE was used to select the optimal model using the smallest value. Resampling results across tuning parameters: Resampling: Rolling Forecasting Origin Resampling (12 held-out with a fixed window) Step 1: Creating the timeSlices for the index of the data: timeSlices str(timeSlices,max.level = 1)įor ease of understanding, I am saving them in separate variable: trainSlices myTimeControl Step 0: Setting up the data and trainControl:(from your question) library(caret) However, here is how to use createTimeSlices for splitting the data and then using it for training and testing a model. Note that the original question that you have posted, takes care of the timeSlicing, and you don't have to create timeSlices by hand.
0 Comments
Leave a Reply. |