I've been reading this code (based on this R package) and I found that the number of non-zero eigenvalues of the estimated covariance is roughly equal to $x_i^T \hat{\Sigma}^{-1} x_i$. I want to know how to arrive at this result.
This arises in the context of Maximum Likelihood estimation of generalized ARMA coefficients. I've made a few tests with data generated from a multivariate normal distribution with random covariance matrices and the results are consistent.
It seems I'm lacking of a little bit of linear algebra
Some background:
- $x_i$ is a real column vector with dimension $d$ (one observation)
- $X = [x_1, x_2, \ldots, x_n]$ with shape $d\times n$ (all the observations)
I want to prove that:
$$\sum_{i=0}^{i=n} x_i^T \hat{\Sigma}^{-1} x_i = n\operatorname{len}(s)$$
being $\operatorname{len}(s)$ the number of non-zero singular values* of $\hat{\Sigma}$, that is defined as
$$\hat{\Sigma} = \frac{1}{n} \sum_{j=1}^{j=n} x_j x_j^T$$
If necessary, mean can be considered $0$
*Not necessarily mathematical $0$, it can also mean "not too small values" .
Actually, "non-zero" means "non-negligible" depending on a threshold defined as the largest singular value times the square root of the machine epsilon.
In Python: s[0] * np.sqrt(np.finfo(np.float).eps)
being s the singular values in descending order (see the code)