predict.mtscp: Make predictions from a '"mtscp"' object

View source: R/predict.R

predict.mtscpR Documentation

Make predictions from a "mtscp" object

Description

This function makes predictions from a "mtscp" object.

Usage

## S3 method for class 'mtscp'
predict(
  object,
  newdata = NULL,
  n.ahead = 10,
  control_ARIMA = list(),
  control_VAR = list(),
  ...
)

Arguments

object

An object of class "mtscp" constructed by CP_MTS.

newdata

Optional. A new data matrix to predict from.

n.ahead

An integer specifying the number of steps ahead for prediction.

control_ARIMA

A list of arguments passed to the function auto.arima() of forecast. See 'Details' and the manual of auto.arima(). The default is list(ic = "aic").

control_VAR

A list of arguments passed to the function VAR() of vars. See 'Details' and the manual of VAR(). The default is list(type = "const", lag.max = 6, ic = "AIC").

...

Currently not used.

Details

Forecasting for {\bf y}_t can be implemented in two steps:

Step 1. Get the h-step ahead forecast of the \hat{d} \times 1 time series \hat{\bf x}_t=(\hat{x}_{t,1},\ldots,\hat{x}_{t,\hat{d}})' [See CP_MTS], denoted by \hat{\bf x}_{n+h}, using a VAR model (if \hat{d} > 1) or an ARIMA model (if \hat{d} = 1). The orders of VAR and ARIMA models are determined by AIC by default. Otherwise, they can also be specified by users through the arguments control_VAR and control_ARIMA, respectively.

Step 2. The forecasted value for {\bf Y}_t is obtained by \hat{\bf Y}_{n+h}= \hat{\bf A} \hat{\bf X}_{n+h} \hat{\bf B}' with \hat{\bf X}_{n+h} = {\rm diag}(\hat{\bf x}_{n+h}).

Value

Y_pred

A list of length n.ahead, where each element is a p \times q matrix representing the predicted values at each time step.

See Also

CP_MTS

Examples

library(HDTSA)
data(FamaFrench, package = "HDTSA")

## Remove the market effects
reg <- lm(as.matrix(FamaFrench[, -c(1:2)]) ~ as.matrix(FamaFrench$MKT.RF))
Y_2d = reg$residuals

## Rearrange Y_2d into a 3-dimensional array Y
Y = array(NA, dim = c(NROW(Y_2d), 10, 10))
for (tt in 1:NROW(Y_2d)) {
  for (ii in 1:10) {
    Y[tt, ii, ] <- Y_2d[tt, (1 + 10*(ii - 1)):(10 * ii)]
  }
}

res_cp <- CP_MTS(Y, lag.k = 20, method = "CP.Refined")
pred_cp_Y <- predict(res_cp, n.ahead = 1)[[1]]


HDTSA documentation built on April 3, 2025, 11:07 p.m.