| ts_lm_mv | R Documentation |
Create a target-centered singular multivariate regressor based on
stats::lm.
ts_lm_mv(models_x = NULL, formula = NULL, features = NULL)
models_x |
Optional named list with one univariate model per auxiliary variable. |
formula |
Optional regression formula. When omitted, the target variable
from |
features |
Optional character vector of feature names used when |
ts_lm_mv() is a linear-regression member of the ts_reg_mv family.
It is inspired by the formula-based design already used in daltoolbox,
but adapted to the aligned multivariate time-series abstraction of
tspredit.
This makes it a very transparent baseline for the singular multivariate branch:
the target variable remains explicit
the auxiliary variables are declared in the formula
the analyst can read the structural assumption directly from the model
The most common usage patterns are:
provide a full formula such as y ~ x1 + x2
omit the formula and let the model regress y on all auxiliary variables
The target variable is forecast from the synchronized auxiliary variables.
When future auxiliary values are not known, they can be generated by the
univariate models supplied in models_x.
A ts_lm_mv object inheriting from ts_reg_mv.
Montgomery DC, Peck EA, Vining GG (2021). Introduction to Linear Regression Analysis. 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_lm_mv(
models_x = list(x1 = ts_arima(), x2 = ts_arima()),
formula = y ~ x1 + x2
)
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.