ts_split: Split Time Series Object for Training and Testing Partitions

View source: R/util_functions.R

ts_splitR Documentation

Split Time Series Object for Training and Testing Partitions

Description

Split a time series object into training and testing partitions

Usage

ts_split(ts.obj, sample.out = NULL)

Arguments

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

Examples


## 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)

RamiKrispin/TSstudio documentation built on Aug. 28, 2023, 11:08 a.m.