Learn R Programming

ForeCA (version 0.2.7)

mvspectrum2wcov: Compute (weighted) covariance matrix from frequency spectrum

Description

mvspectrum2wcov computes a (weighted) covariance matrix estimate from the frequency spectrum (see Details).

weightvector2entropy_wcov computes the weighted covariance matrix using the negative entropy of the univariate spectrum (given the weightvector) as kernel weights. This matrix is the objective matrix for many foreca.* algorithms.

Usage

mvspectrum2wcov(mvspectrum.output, kernel.weights = 1)

weightvector2entropy_wcov( weightvector = NULL, f.U, f.current = NULL, entropy.control = list() )

Arguments

mvspectrum.output

an object of class "mvspectrum" representing the multivariate spectrum of \(\mathbf{X}_t\) (not necessarily normalized).

kernel.weights

numeric; weights for each frequency. By default uses weights that average out to 1.

weightvector

numeric; weights \(\mathbf{w}\) for \(y_t = \mathbf{U}_t \mathbf{w}\). Must have unit norm in \(\ell^2\).

f.U

multivariate spectrum of class 'mvspectrum' with normalize = TRUE.

f.current

numeric; spectral density estimate of \(y_t=\mathbf{U}_t \mathbf{w}\) for the current estimate \(\widehat{\mathbf{w}}_i\) (required for foreca.EM.M_step; optional for foreca.EM.h).

entropy.control

list; control settings for entropy estimation. See complete_entropy_control for details.

Value

A symmetric \(n \times n\) matrix.

If kernel.weights \(\geq 0\), then it is positive semi-definite; otherwise, it is symmetric but not necessarily positive semi-definite.

Details

The covariance matrix of a multivariate time series satisfies the identity $$ \Sigma_{X} \equiv \int_{-\pi}^{\pi} S_{X}(\lambda) d \lambda. $$

A generalized covariance matrix estimate can thus be obtained using a weighted average $$ \tilde{\Sigma}_X = \int_{-\pi}^{\pi} K(\lambda) S_{X}(\lambda) d \lambda, $$ where \(K(\lambda)\) is a kernel symmetric around \(0\) which averages out to \(1\) over the interval \([-\pi, \pi]\), i.e., \(\frac{1}{2 \pi} \int_{-\pi}^{\pi} K(\lambda) d \lambda = 1\). This allows one to remove or amplify specific frequencies in the covariance matrix estimation.

For ForeCA mvspectrum2wcov is especially important as we use $$ K(\lambda) = -\log f_y(\lambda), $$ as the weights (their average is not \(1\)!). This particular kernel weight is implemented as a wrapper in weightvector2entropy_wcov.

See Also

mvspectrum

Examples

Run this code
# NOT RUN {
nn <- 50
YY <- cbind(rnorm(nn), arima.sim(n = nn, list(ar = 0.9)), rnorm(nn))
XX <- YY %*% matrix(rnorm(9), ncol = 3)  # random mix
XX <- scale(XX, scale = FALSE, center = TRUE)

# sample estimate of covariance matrix
Sigma.hat <- cov(XX)
dimnames(Sigma.hat) <- NULL

# using the frequency spectrum
SS <- mvspectrum(XX, "mvspec")
Sigma.hat.freq <- mvspectrum2wcov(SS)

layout(matrix(1:4, ncol = 2))
par(mar = c(2, 2, 1, 1))
plot(c(Sigma.hat/Sigma.hat.freq))
abline(h = 1)

image(Sigma.hat)
image(Sigma.hat.freq)
image(Sigma.hat / Sigma.hat.freq)

# examples for entropy wcov
XX <- diff(log(EuStockMarkets)) * 100
UU <- whiten(XX)$U
ff <- mvspectrum(UU, "mvspec", normalize = TRUE)

ww0 <- initialize_weightvector(num.series = ncol(XX), method = 'rnorm')

weightvector2entropy_wcov(ww0, ff,
                          entropy.control = 
                            list(prior.weight = 0.1))
# }

Run the code above in your browser using DataLab