odpc | R Documentation |
Computes One-Sided Dynamic Principal Components for a given number of lags.
odpc(Z, ks, method, tol = 1e-04, niter_max = 500)
Z |
Data matrix. Each column is a different time series. |
ks |
Matrix or vector of integers. If a matrix, each row is the vector with number of lags to use for each component. First column has the number of lags used to define the dynamic principal component (k_1), second column has the number of lags of the dynamic principal component used to reconstruct the series (k_2). If a vector, its entries are taken as both k_1 and k_2 for each component |
method |
A string specifying the algorithm used. Options are 'ALS', 'mix' or 'gradient'. See details below. |
tol |
Relative precision. Default is 1e-4. |
niter_max |
Integer. Maximum number of iterations. Default is 500. |
Consider the vector time series \mathbf{z}_{1},…,\mathbf{z}_{T}, where \mathbf{z}_{t}=(z_{t,1},…,z_{t,m})^{\prime}. Let \mathbf{a}% =(\mathbf{a}_{0}^{\prime},…,\mathbf{a}_{k_{1}}^{\prime})^{\prime}, where \mathbf{a}_{h}^{\prime}=(a_{h,1},...,a_{h,m}), be a vector of dimension m(k_{1}+1)\times1, let \boldsymbol{α}^{\prime}=(α_{1}% ,…,α_{m}) and \mathbf{B} the matrix that has coefficients b_{h,j} and dimension (k_{2}+1)\times m. Consider
f_{t}=∑\limits_{j=1}^{m}∑\limits_{h=0}^{k_{1}}a_{h,j}z_{t-h,j}\quad t=k_{1}+1,…,T, \nonumber
and suppose we use f_t and k_{2} of its lags to reconstruct the series as
z_{t,j}^{R}(\mathbf{a},\boldsymbol{α},\mathbf{B)}=α_{j} +∑\limits_{h=0}^{k_{2}}b_{h,j}f_{t-h}.\nonumber
Let
MSE(\mathbf{a},\boldsymbol{α},\mathbf{B})=\frac{1}{T-(k_{1}% +k_{2})}∑\limits_{j=1}^{m}∑\limits_{t=(k_{1}+k_{2}% )+1}^{T}(z_{t,j}-z_{t,j}^{R}(\mathbf{a},\boldsymbol{α},\mathbf{B)})^{2}
be the reconstruction MSE. The first one-sided dynamic principal component is defined as the series
\widehat{f}_{t}=∑\limits_{j=1}^{m}∑\limits_{h=0}^{k_{1}}\widehat{a}_{h,j}z_{t-h,j}\quad t=k_{1}+1,…,T, \nonumber
for optimal values (\widehat{\mathbf{a}},\widehat{\boldsymbol{α}}% ,\widehat{\mathbf{B}}) that satisfy
MSE(\widehat{\mathbf{a}},\widehat{\boldsymbol{α}}% ,\widehat{\mathbf{B}})=\min_{\Vert\mathbf{a}\Vert=1,\boldsymbol{α },\mathbf{B}}MSE(\mathbf{a},\boldsymbol{α},\mathbf{B}). \nonumber
The second one-sided dynamic principal component is defined similarly, but now the residuals of the first one-sided dynamic principal component are to be reconstructed.
If method = 'ALS', an Alternating Least Squares type algorithm is used to compute the solution. If 'mix' is chosen, in each iteration Least Squares is used to compute the matrix of loadings and intercepts, but one iteration of Coordinate Descent is performed to compute the vector a that defines the dynamic principal component. If method = 'gradient', in each iteration Least Squares is used to compute the matrix of loadings and intercepts, but one iteration of Gradient Descent is performed to compute the vector a that defines the dynamic principal component. By default, 'ALS' is used when the number of series is less than 10, else 'gradient' is used.
An object of class odpcs
, that is, a list of length equal to the number of computed components. The i-th entry of this list is an object of class odpc
, that is, a list with entries
f |
Coordinates of the i-th dynamic principal component corresponding to the periods k_1 + 1,…,T. |
mse |
Mean squared error of the reconstruction using the first i components. |
k1 |
Number of lags used to define the i-th dynamic principal component f. |
k2 |
Number of lags of f used to reconstruct. |
alpha |
Vector of intercepts corresponding to f. |
a |
Vector that defines the i-th dynamic principal component |
B |
Matrix of loadings corresponding to f. Row number k is the vector of k-1 lag loadings. |
call |
The matched call. |
conv |
Logical. Did the iterations converge? |
components
, fitted
, plot
and print
methods are available for this class.
Peña D., Smucler E. and Yohai V.J. (2019). “Forecasting Multiple Time Series with One-Sided Dynamic Principal Components.” Journal of the American Statistical Association.
crit.odpc
, cv.odpc
, plot.odpc
, fitted.odpcs
, components_odpcs
, forecast.odpcs
T <- 200 #length of series m <- 10 #number of series set.seed(1234) f <- rnorm(T + 1) x <- matrix(0, T, m) u <- matrix(rnorm(T * m), T, m) for (i in 1:m) { x[, i] <- 10 * sin(2 * pi * (i/m)) * f[1:T] + 10 * cos(2 * pi * (i/m)) * f[2:(T + 1)] + u[, i] } fit <- odpc(x, ks = c(1)) fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.