ts_sample {daltoolbox} | R Documentation |
Time Series Sample
Description
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.
Usage
ts_sample(ts, test_size = 1, offset = 0)
Arguments
ts |
time series. |
test_size |
integer: size of test data (default = 1). |
offset |
integer: starting point (default = 0). |
Value
A list with the two samples
Examples
#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)
[Package daltoolbox version 1.0.767 Index]