Learn R Programming

odpc (version 2.0.5)

odpc: Fitting of One-Sided Dynamic Principal Components

Description

Computes One-Sided Dynamic Principal Components for a given number of lags.

Usage

odpc(Z, ks, method, tol = 1e-04, niter_max = 500)

Arguments

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.

Value

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,\dots,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.

Details

Consider the vector time series \(\mathbf{z}_{1},\dots,\mathbf{z}_{T}\), where \(\mathbf{z}_{t}=(z_{t,1},\dots,z_{t,m})^{\prime}\). Let \(\mathbf{a}% =(\mathbf{a}_{0}^{\prime},\dots,\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{\alpha}^{\prime}=(\alpha_{1}% ,\dots,\alpha_{m})\) and \(\mathbf{B}\) the matrix that has coefficients \(b_{h,j}\) and dimension \((k_{2}+1)\times m\). Consider $$ f_{t}=\sum\limits_{j=1}^{m}\sum\limits_{h=0}^{k_{1}}a_{h,j}z_{t-h,j}\quad t=k_{1}+1,\dots,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{\alpha},\mathbf{B)}=\alpha_{j} +\sum\limits_{h=0}^{k_{2}}b_{h,j}f_{t-h}.\nonumber $$ Let $$ MSE(\mathbf{a},\boldsymbol{\alpha},\mathbf{B})=\frac{1}{T-(k_{1}% +k_{2})}\sum\limits_{j=1}^{m}\sum\limits_{t=(k_{1}+k_{2}% )+1}^{T}(z_{t,j}-z_{t,j}^{R}(\mathbf{a},\boldsymbol{\alpha},\mathbf{B)})^{2} $$ be the reconstruction MSE. The first one-sided dynamic principal component is defined as the series $$ \widehat{f}_{t}=\sum\limits_{j=1}^{m}\sum\limits_{h=0}^{k_{1}}\widehat{a}_{h,j}z_{t-h,j}\quad t=k_{1}+1,\dots,T, \nonumber $$ for optimal values \((\widehat{\mathbf{a}},\widehat{\boldsymbol{\alpha}}% ,\widehat{\mathbf{B}})\) that satisfy $$ MSE(\widehat{\mathbf{a}},\widehat{\boldsymbol{\alpha}}% ,\widehat{\mathbf{B}})=\min_{\Vert\mathbf{a}\Vert=1,\boldsymbol{\alpha },\mathbf{B}}MSE(\mathbf{a},\boldsymbol{\alpha},\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.

References

Pe<U+00F1>a D., Smucler E. and Yohai V.J. (2019). <U+201C>Forecasting Multiple Time Series with One-Sided Dynamic Principal Components.<U+201D> Journal of the American Statistical Association.

See Also

crit.odpc, cv.odpc, plot.odpc, fitted.odpcs, components_odpcs, forecast.odpcs

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab