Learn R Programming

HDTSA (version 1.0.5)

predict.tspca: Make predictions from a "tspca" object

Description

This function makes predictions from a "tspca" object.

Usage

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

Value

Y_pred

A matrix of predicted values.

Arguments

object

An object of class "tspca" constructed by PCA_TS.

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(max.d = 0, max.q = 0, 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

Having obtained \(\hat{\bf x}_t\) using the PCA_TS function, which is segmented into \(q\) uncorrelated subseries \(\hat{\bf x}_t^{(1)},\ldots,\hat{\bf x}_t^{(q)}\), the forecasting for \({\bf y}_t\) can be performed in two steps:

Step 1. Get the \(h\)-step ahead forecast \(\hat{\bf x}_{n+h}^{(j)}\) \((j=1,\ldots,q)\) by using a VAR model (if the dimension of \(\hat{\bf x}_t^{(j)}\) is larger than 1) or an ARIMA model (if the dimension of \(\hat{\bf x}_t^{(j)}\) is 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. Let \(\hat{\bf x}_{n+h} = (\{\hat{\bf x}_{n+h}^{(1)}\}',\ldots,\{\hat{\bf x}_{n+h}^{(q)}\}')'\). The forecasted value for \({\bf y}_t\) is obtained by \(\hat{\bf y}_{n+h}= \hat{\bf B}^{-1}\hat{\bf x}_{n+h}\).

See Also

PCA_TS

Examples

Run this code
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

res_pca <- PCA_TS(Y_2d, lag.k = 5, thresh = TRUE)
pred_pca_Y <- predict(res_pca, n.ahead = 1)


Run the code above in your browser using DataLab