Ketika menghitung matriks kovarians sampel, adakah yang dijamin mendapatkan matriks simetris dan pasti positif?
Saat ini masalah saya memiliki sampel 4600 vektor pengamatan dan 24 dimensi.
Ketika menghitung matriks kovarians sampel, adakah yang dijamin mendapatkan matriks simetris dan pasti positif?
Saat ini masalah saya memiliki sampel 4600 vektor pengamatan dan 24 dimensi.
Jawaban:
Untuk sampel vektor , dengan , vektor mean sampel adalah
The additional condition for to be positive definite was given in whuber's comment bellow. It goes as follows.
Define , for . For any nonzero , is zero if and only if , for each . Suppose the set spans , yielding that , a contradiction. Hence, if the 's span , then is positive definite. This condition is equivalent to .
A correct covariance matrix is always symmetric and positive *semi*definite.
The covariance between two variables is defied as .
This equation doesn't change if you switch the positions of and . Hence the matrix has to be symmetric.
It also has to be positive *semi-*definite because:
You can always find a transformation of your variables in a way that the covariance-matrix becomes diagonal. On the diagonal, you find the variances of your transformed variables which are either zero or positive, it is easy to see that this makes the transformed matrix positive semidefinite. However, since the definition of definity is transformation-invariant, it follows that the covariance-matrix is positive semidefinite in any chosen coordinate system.
When you estimate your covariance matrix (that is, when you calculate your sample covariance) with the formula you stated above, it will obv. still be symmetric. It also has to be positive semidefinite (I think), because for each sample, the pdf that gives each sample point equal probability has the sample covariance as its covariance (somebody please verify this), so everything stated above still applies.
Variance-Covariance matrices are always symmetric, as it can be proven from the actual equation to calculate each term of said matrix.
Also, Variance-Covariance matrices are always square matrices of size n, where n is the number of variables in your experiment.
Eigenvectors of symmetric matrices are always orthogonal.
With PCA, you determine the eigenvalues of the matrix to see if you could reduce the number of variables used in your experiment.
I would add to the nice argument of Zen the following which explains why we often say that the covariance matrix is positive definite if .
If are a random sample of a continuous probability distribution then are almost surely (in the probability theory sense) linearly independent. Now, are not linearly independent because , but because of being a.s. linearly independent, a.s. span . If , they also span .
To conclude, if are a random sample of a continuous probability distribution and , the covariance matrix is positive definite.
For those with a non-mathematical background like me who don't quickly catch the abstract mathematical formulae, this is a worked out example excel for the most upvoted answer. The covariance matrix can be derived in other ways also.