Split a time series object into training and testing partitions
ts_split(ts.obj, sample.out = NULL)
ts.obj | A univariate time series object of a class "ts" or "tsibble" |
---|---|
sample.out | 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)#> [1] 238length(training)#> [1] 226length(testing)#> [1] 12