mvspectrum2wcov {ForeCA} | R Documentation |
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 |
kernel.weights |
numeric; weights for each frequency. By default uses
weights that average out to |
weightvector |
numeric; weights |
f.U |
multivariate spectrum of class |
f.current |
numeric; spectral density estimate of
|
entropy.control |
list; control settings for entropy estimation.
See |
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
.
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.
See Also
Examples
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))