Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Problem with Cholesky matrix function?


From   May Boggess <[email protected]>
To   [email protected]
Subject   Re: st: Problem with Cholesky matrix function?
Date   24 Nov 2003 08:59:02 -0600

On Sun, 2003-11-23 at 19:14, Kaleb Michaud wrote:

> symmetric S[10,10]
>        r1   r2   r3   r4   r5   r6   r7   r8   r9  r10
>   c1    1
>   c2    2    2
>   c3    3    3    3
>   c4    4    4    4    4
>   c5    5    5    5    5    5
>   c6    6    6    6    6    6    6
>   c7    7    7    7    7    7    7    7
>   c8    8    8    8    8    8    8    8    8
>   c9    9    9    9    9    9    9    9    9    9
> c10   10   10   10   10   10   10   10   10   10   10
> 
> The problem is this:
> 
> . matrix C = cholesky(S)
> matrix not positive definite
> r(506);
> 

For a matrix to be positive definite it needs to have all positive
eigenvalues. So, Kaleb can check his matrix by using -symeigen- to
compute the eigenvalues of S. I have pasted some code below that does
this. 

Out of curiosity I also looked at the matrices that had the same pattern
in the entries as S, but smaller sizes, and found that they had similar
structure to the eigenvalues, that is, they all have one large positive
eigenvalue and the rest negative. The code below will run these cases as
well.


yours,
--May

[email protected]


matrix S=[1,2,3,4,5,6,7,8,9,10\2,2,3,4,5,6,7,8,9,10\3,3,3,4,5,6,7,8,9,10\ /*
  */4,4,4,4,5,6,7,8,9,10\5,5,5,5,5,6,7,8,9,10\6,6,6,6,6,6,7,8,9,10\ /*
  */ 7,7,7,7,7,7,7,8,9,10\8,8,8,8,8,8,8,8,9,10\9,9,9,9,9,9,9,9,9,10\ /*
   */10,10,10,10,10,10,10,10,10,10]
mat list S
mat symeigen X v = S
mat list v

matrix S=[1,2,3,4,5,6,7,8,9\2,2,3,4,5,6,7,8,9\3,3,3,4,5,6,7,8,9\ /*
    */4,4,4,4,5,6,7,8,9\5,5,5,5,5,6,7,8,9\6,6,6,6,6,6,7,8,9\ /*
    */7,7,7,7,7,7,7,8,9\8,8,8,8,8,8,8,8,9\9,9,9,9,9,9,9,9,9]
mat list S
mat symeigen X v = S
mat list v

matrix S=[1,2,3,4,5,6,7,8\2,2,3,4,5,6,7,8\3,3,3,4,5,6,7,8\ /*
    */4,4,4,4,5,6,7,8\5,5,5,5,5,6,7,8\6,6,6,6,6,6,7,8\ /*
    */7,7,7,7,7,7,7,8\8,8,8,8,8,8,8,8]
mat list S
mat symeigen X v = S
mat list v


matrix S=[1,2,3,4,5,6,7\2,2,3,4,5,6,7\3,3,3,4,5,6,7\ /*
    */4,4,4,4,5,6,7\5,5,5,5,5,6,7\6,6,6,6,6,6,7\ /*
    */7,7,7,7,7,7,7]
mat list S
mat symeigen X v = S
mat list v


matrix S=[1,2,3,4,5,6\2,2,3,4,5,6\3,3,3,4,5,6\ /*
    */4,4,4,4,5,6\5,5,5,5,5,6\6,6,6,6,6,6]
mat list S
mat symeigen X v = S
mat list v

matrix S=[1,2,3,4,5\2,2,3,4,5\3,3,3,4,5\ /*
    */4,4,4,4,5\5,5,5,5,5]
mat list S
mat symeigen X v = S
mat list v

matrix S=[1,2,3,4\2,2,3,4\3,3,3,4\4,4,4,4]
mat list S
mat symeigen X v = S
mat list v

matrix S=[1,2,3\2,2,3\3,3,3]
mat list S
mat symeigen X v = S
mat list v

matrix S=[1,2\2,2]
 
mat list S
mat symeigen X v = S
mat list v





*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index