# [R] covariance = diagonal + F'F

Thomas W Blackwell tblackw at umich.edu
Sun Apr 20 20:56:07 CEST 2003

```Vadim  -

Use  svd()  or  eigen()  to get the eigenvectors and eigenvalues
of a covariance matrix.  svd() gives them without calculating the
matrix product first, so it is preferable numerically.  For your
sum-of-matrices decomposition, I think you'll have to calculate
the covariance matrix minus its diagonal first, and expect the
result not to be positive definite.  Then calculate eigenvectors
and eigenvalues of that and truncate the number retained.  "Best"
is entirely subjective.

I do not recall this sum decomposition from a previous thread.

HTH  -  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Sun, 20 Apr 2003, Vadim Ogranovich wrote:

> Dear R-Helpers,
>
> I have a n*m data matrix (n is the number of observations) and I want to
> estimate its covariance matrix as a sum of a diagonal matrix and a low-rank
> matrix F'F, where F is p*m matrix (sometimes called "factors"), p<<m, and F'
> is F transpose.
>
> My questions are:
> 1. Given the number of factors p is there an R function that finds the best
> F?
> 2. How to select the "best" p?
>
> Somehow I feel like this was already discussed on the list (but I couldn't
> find it in the archives). If this is the case what was the subject of that