# [R] Non-positive definite cross-covariance matrices

Jeff Bassett jbassett at cs.gmu.edu
Tue Nov 16 18:40:46 CET 2010

```Giovanni,

Both matrices describing the points (A and B in my example) are the
same size, so the resulting matrix will always be square.  Also, the
equation I'm using is essentially the following identity:

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

All the covariance matrices that result from the Var() terms should be
positive definite, and while it seems possible that either of those
resulting from the Cov() terms may not be, the sum of the two should.
Do you agree?

Of course, the above identity only holds if the data is normally
distributed.  The Mardia test for multivariate normality in fact shows
that my data is not.  This may ultimately be my problem.  So maybe I
should be asking if you could point me toward some packages that can
transform my data so that it is normally distributed.

- Jeff

On Mon, Nov 15, 2010 at 3:56 PM, Giovanni Petris <gpetris at uark.edu> wrote:
> What made you think that a cross-covariance matrix should be positive
> definite? Id does not even need to be a square matrix, or symmetric.
>
> Giovanni Petris
>
> On Mon, 2010-11-15 at 12:58 -0500, Jeff Bassett wrote:
>> I am creating covariance matrices from sets of points, and I am having
>> frequent problems where I create matrices that are non-positive
>> definite.  I've started using the corpcor package, which was
>> specifically designed to address these types of problems.  It has
>> solved many of my problems, but I still have one left.
>>
>> One of the matrices I need to calculate is a cross-covariance matrix.
>> In other words, I need to calculate cov(A, B), where A and B are each
>> a matrix defining a set of points.  The corpcor package does not seem
>> to be able to perform this operation.
>>
>> Can anyone suggest a way to create cross-covariance matrices that are
>> guaranteed (or at least likely) to be positive definite, either using
>> corpcor or another package?
>>
>> I'm using R 2.8.1 and corpcor 1.5.2 on Mac OS X 10.5.8.
>>
>> - Jeff
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>

```