predict.mtscp | R Documentation |
"mtscp"
objectThis function makes predictions from a "mtscp"
object.
## S3 method for class 'mtscp'
predict(
object,
newdata = NULL,
n.ahead = 10,
control_ARIMA = list(),
control_VAR = list(),
...
)
object |
An object of class |
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
|
control_VAR |
A list of arguments passed to the function
|
... |
Currently not used. |
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})
.
Y_pred |
A list of length |
CP_MTS
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]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.