| ts_var | R Documentation |
Create a target-centered vector autoregression over aligned multivariate observations.
ts_var(target = NULL, p = NULL, p_max = 5, intercept = TRUE)
target |
Optional target variable name. When omitted, use the |
p |
Optional lag order. When |
p_max |
Maximum lag order considered in the automatic search. |
intercept |
Logical. Whether to include an intercept in each equation. |
ts_var() models the multivariate system directly, but keeps the tspredit
interface centered on a distinguished target variable y.
This means:
the full system is learned jointly
predict() returns the target forecast by default
predict(..., return_all = TRUE) exposes the forecast path of all system
variables
The current implementation uses ordinary least squares over lagged aligned
observations and can choose the lag order automatically by minimizing AICc
over 1:p_max.
This makes ts_var() conceptually different from ts_arimax():
ts_arimax() treats the auxiliaries as regressors for one main target
ts_var() treats all variables as part of the dynamic system
Even so, tspredit still lets the user mark one variable as the main target
for evaluation and default return behavior.
A ts_var object inheriting from ts_reg_mv.
Lütkepohl H (2005). New Introduction to Multiple Time Series Analysis. Springer.
Tsay RS (2014). Multivariate Time Series Analysis with R and Financial Applications. Wiley.
data(tsd)
x1 <- c(tsd$y[-1], tail(tsd$y, 1))
x2 <- stats::filter(tsd$y, rep(1/3, 3), sides = 1)
x2[is.na(x2)] <- tsd$y[is.na(x2)]
mv <- ts_data_mv(data.frame(y = tsd$y, x1 = x1, x2 = as.numeric(x2)), y = "y")
samp <- ts_sample(mv, test_size = 5)
model <- ts_var(p_max = 3)
model <- daltoolbox::fit(model, samp$train)
predict(model, steps_ahead = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.