Learn R Programming

tspredit (version 1.2.767)

ts_data: ts_data

Description

Construct a time series data object used throughout the DAL Toolbox.

Accepts either a vector (raw time series) or a matrix/data.frame already organized in sliding windows. Internally, a ts_data is stored as a matrix with sw lag columns named t{lag} (e.g., t9, t8, ..., t0). When sw is zero or one, the series is stored as a single column (t0).

Usage

ts_data(y, sw = 1)

Value

A ts_data object (matrix with attributes and column names).

Arguments

y

Numeric vector or matrix-like. Time series values or sliding windows.

sw

Integer. Sliding-window size (number of lag columns).

Examples

Run this code
# Example: building sliding windows
data(tsd)
head(tsd)

# 1) Single-column ts_data (no windows)
data <- ts_data(tsd$y)
ts_head(data)

# 2) 10-lag sliding windows (t9 ... t0)
data10 <- ts_data(tsd$y, 10)
ts_head(data10)

Run the code above in your browser using DataLab