November 2017
Beginner to intermediate
366 pages
7h 59m
English
Let us split our data into training and test datasets. Out of the whole time series, we will use 80% of the data for training and the rest for testing. We need to keep the order of the time series intact while splitting it.
Split the data as follows:
train.perc = 0.8train.indx = 1:as.integer(dim(final.data)[1] * train.perc)train.data <- final.data[train.indx,]test.data <- final.data[-train.indx ,]
train.data contains 80% of our data and test.data now contains the final 20%.
Let us now split the data into the dependent variable, y, and independent variable, x:
train.x.data <- data.matrix(train.data[,-1])train.y.data <- train.data[,1]test.x.data <- data.matrix(test.data[,-1])test.y.data <- test.data[,1]
We convert our x ...
Read now
Unlock full access