ts_arimax: ARIMAX

View source: R/ts_arimax.R

ts_arimaxR Documentation

ARIMAX

Description

Create a target-centered multivariate regressor based on ARIMA with external regressors.

Usage

ts_arimax(models_x = NULL, p = NULL, d = NULL, q = NULL)

Arguments

models_x

Optional named list with one univariate model per auxiliary variable.

p

Optional integer autoregressive order. Leave NULL to let auto.arima() choose it.

d

Optional integer differencing order. Leave NULL to let auto.arima() choose it.

q

Optional integer moving-average order. Leave NULL to let auto.arima() choose it.

Details

ts_arimax() is the singular multivariate counterpart of ts_arima().

The model keeps one target variable y as the main forecasting objective and uses the aligned auxiliary variables ⁠x1, ..., xn⁠ as regressors through the xreg mechanism of the forecast package.

This is the natural choice when the user thinks in the following way:

  • there is one main series y

  • the remaining variables help explain or anticipate y

  • the primary output is the future path of y

In other words, ts_arimax() is a target-centered multivariate model, not a symmetric system model like ts_var().

For multi-step forecasting, future auxiliary values can be supplied directly or generated by the auxiliary univariate models stored in models_x.

This makes ts_arimax() a natural member of the new ts_reg_mv branch:

  • the target forecast remains central

  • the aligned multivariate system is still available when return_all = TRUE

  • auxiliary series can be modeled separately when their future path is not known beforehand

The current implementation follows the same philosophy as ts_arima():

  • if p, d, and q are supplied, fit that specific order

  • otherwise use forecast::auto.arima() on the target with xreg

This keeps the singular multivariate branch consistent with the existing raw univariate branch of the package.

Value

A ts_arimax object inheriting from ts_reg_mv.

References

  • Box GEP, Jenkins GM, Reinsel GC, Ljung GM (2015). Time Series Analysis: Forecasting and Control. Wiley.

  • Hyndman RJ, Athanasopoulos G (2021). Forecasting: Principles and Practice. Third Edition. OTexts. https://otexts.com/fpp3/

Examples

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_arimax(models_x = list(x1 = ts_arima(), x2 = ts_arima()))
model <- daltoolbox::fit(model, samp$train)
predict(model, steps_ahead = 5)

tspredit documentation built on Sept. 9, 2026, 9:08 a.m.