gdpc (version 1.0.2)

gdpc: Generalized Dynamic Principal Components

Description

Computes a single Generalized Dynamic Principal Component with a given number of lags.

Usage

gdpc(Z, k, f_ini = NULL, tol = 1e-4, niter_max = 500, crit = 'LOO')

Arguments

Z

Data matrix. Each column is a different time series.

k

Integer. Number of lags to use.

f_ini

(Optional). Numeric vector. Starting point for the iterations. If no argument is passed the ordinary (non-dynamic) first principal component completed with k lags is used.

tol

Relative precision. Default is 1e-4.

niter_max

Integer. Maximum number of iterations. Default is 500.

crit

A string specifying the criterion to be used to evaluate the fitted model. Options are 'LOO', 'AIC', 'BIC' and 'BNG'. Default is 'LOO'.

Value

An object of class gdpc, that is, a list with entries:

expart

Proportion of the variance explained.

mse

Mean squared error.

crit

The value of the criterion of the reconstruction, according to what the user specified.

k

Number of lags used.

alpha

Vector of intercepts corresponding to f.

beta

Matrix of loadings corresponding to f. Column number \(k\) is the vector of \(k-1\) lag loadings.

f

Coordinates of the first dynamic principal component corresponding to the periods \(1,\dots,T\).

initial_f

Coordinates of the first dynamic principal component corresponding to the periods \(-k+1,\dots,0\). Only for the case \(k>0\), otherwise 0.

call

The matched call.

conv

Logical. Did the iterations converge?

fitted, plot and print methods are available for this class.

Details

See auto.gdpc for the definition of criterion that is part of the output of this function.

See Also

auto.gdpc, plot.gdpc

Examples

Run this code
# NOT RUN {
T <- 200 #length of series
m <- 500 #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 <- gdpc(x, k = 1) #find first DPC with one lag
fit
par(mfrow = c(1, 2)) #plot loadings
plot(fit, which = 'Loadings', which_load = 0, xlab = '', ylab = '') 
plot(fit, which = 'Loadings', which_load = 1, xlab = '', ylab = '') 
# }

Run the code above in your browser using DataCamp Workspace