
Last chance! 50% off unlimited learning
Sale ends in
Split a time series object into training and testing partitions
ts_split(ts.obj, sample.out = NULL)
A univariate time series object of a class "ts" or "tsibble"
An integer, set the number of periods of the testing or sample out partition, defualt set for 30 percent of the lenght of the series
## Split the USgas dataset into training and testing partitions
## Set the last 12 months as a testing partition
## and the rest as a training partition
data(USgas, package = "TSstudio")
split_USgas <- ts_split(ts.obj = USgas, sample.out = 12)
training <- split_USgas$train
testing <- split_USgas$test
length(USgas)
length(training)
length(testing)
Run the code above in your browser using DataLab