ts_sample | R Documentation |
Separates the ts_data
into training and test.
It separates the test size from the last observations minus an offset.
The offset is important to allow replication under different recent origins.
The data for train uses the number of rows of a ts_data
minus the test size and offset.
ts_sample(ts, test_size = 1, offset = 0)
ts |
time series. |
test_size |
integer: size of test data (default = 1). |
offset |
integer: starting point (default = 0). |
returns a list with the two samples
#setting up a ts_data
data(sin_data)
ts <- ts_data(sin_data$y, 10)
#separating into train and test
test_size <- 3
samp <- ts_sample(ts, test_size)
#first five rows from training data
ts_head(samp$train, 5)
#last five rows from training data
ts_head(samp$train[-c(1:(nrow(samp$train)-5)),])
#testing data
ts_head(samp$test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.