There's more...

The caret package has also a function to select subsets of data from a time series. This is the createTimeSlices() function. It needs three parameters: the first one is the vector of data; the second one is the number of elements to keep in train; and the third one is the horizon (periods that are kept for the testing data). In this example, we will generate 10 random numbers that simulate a time series, and we will split it into training sets of 4 elements, and testing sets of 2.

r = rnorm(10,0,1)
createTimeSlices(r,4, horizon=2)

Take a look at the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.89.89