[R] Non-positive definite cross-covariance matrices

Jeff Bassett jbassett at cs.gmu.edu
Wed Nov 17 02:19:25 CET 2010


On Tue, Nov 16, 2010 at 1:49 PM, Peter Langfelder
<peter.langfelder at gmail.com> wrote:
>
> It is easy to come up with examples where Cov(A, B) + Cov(B, A) is not
> positive definite. As an extreme example, consider a matrix A (say 10
> columns, 100 rows) such that the off-diagonal covariances are all zero
> and the columns are standardized, so cov(A) = diag(1, 1, 1, ...). Then
> take B = -A, so cov(A, B) = cov(B, A) = diag(-1, -1, -1, ...).
> Obviously, cov(A, B) + cov(B, A) is not positively definite, in fact
> it is negative definite.

Peter,

I see your point.  As it turns out though, what I'm trying to
calculate is heritability using a slightly modified version of an
equation from multivariate quantitative genetics.  Theoretically I
suppose a heritability matrix could be non-positive definite, but in
practice it almost never is, at least from what I understand.

I think I've found a solution to my problem though.  The equation I
showed before can be rearranged so that the cross-covariance terms are
described in terms of the Var() terms.

Cov(A, B) + Cov(B, A) = Var(A) + Var(B) - Var(A + B)

Since the corpcor package can calculate positive definite versions of
all the Var() terms, I can then calculate the sum of the
cross-covariance terms from those.  I've done some preliminary tests,
and it seems to be working quite well.

Thanks for all the help,
- Jeff



More information about the R-help mailing list