hello to all
I want to estimate eigenvalues of non-symmetric matrices using SPSS syntax. below matrix is an example. can anyone tell me how we can get eigenvalues of a non-symmetric matrix in SPSS syntax. MATRIX. COMP S={0.2273, -0.0852; -0.1930,0.1794}. CALL EIGEN(S,VECTOR,VALUE). PRINT VECTOR. PRINT VALUE. END MATRIX. with best regards, Asghar Minaei |
Administrator
|
MATRIX. COMPUTE S={0.2273, -0.0852; -0.1930,0.1794}. CALL SVD (S,U,Q,V). PRINT {U,Q,V}. PRINT (S-(U * Q * T(V))) /FORMAT "F20.18". END MATRIX. From the FM: "SVD(M,var1,var2,var3). Singular value decomposition of a matrix. Takes four arguments: a matrix and three valid variable names to which the results are assigned. If M is a matrix, the statement CALL SVD(M,U,Q,V) will assign to Q a diagonal matrix of the same dimensions as M, and to U and V unitary matrices (matrices whose inverses equal their transposes) of appropriate dimensions, such that M=U*Q* T(V), where T is the transpose function defined above. The singular values of M are in the main diagonal of Q."
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
David, nope, the OP wants eigendecomposition of the asymmetric
matrix which isn't the same as SVD.
SPSS has no such a function. 21.11.2013 0:18, David Marso пишет:
MATRIX. COMPUTE S={0.2273, -0.0852; -0.1930,0.1794}. CALL SVD (S,U,Q,V). PRINT {U,Q,V}. PRINT (S-(U * Q * T(V))) /FORMAT "F20.18". END MATRIX. >From the FM: "SVD(M,var1,var2,var3). Singular value decomposition of a matrix. Takes four arguments: a matrix and three valid variable names to which the results are assigned. If M is a matrix, the statement CALL SVD(M,U,Q,V) will assign to Q a diagonal matrix of the same dimensions as M, and to U and V unitary matrices (matrices whose inverses equal their transposes) of appropriate dimensions, such that M=U*Q* T(V), where T is the transpose function defined above. The singular values of M are in the main diagonal of Q." asghar wrotehello to all I want to estimate eigenvalues of non-symmetric matrices using SPSS syntax. below matrix is an example. can anyone tell me how we can get eigenvalues of a non-symmetric matrix in SPSS syntax. MATRIX. COMP S={0.2273, -0.0852; -0.1930,0.1794}. CALL EIGEN(S,VECTOR,VALUE). PRINT VECTOR. PRINT VALUE. END MATRIX. with best regards, Asghar Minaei----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/spss-sYntax-to-get-eigenvalues-tp5723185p5723202.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
Kirill,
Please enlighten the class as to how an SVD is NOT the same as an eigendecomposition. In my example Q are eigenvalues, U and V are orthonormal . If one does an SVD of a symmetrical matrix the results are identical to EIGEN.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Kirill, Please enlighten the class as to how an SVD is NOT the same as an eigendecomposition. In my example Q are eigenvalues, U and V are orthonormal . If one does an SVD of a symmetrical matrix the results are identical to EIGEN. Eigenvalue problem is A = V*D*inv(V), where A is square decomposed matrix, D is diagonal matrix with eigenvalues , V is the eigenvectors. Note - there is only one type of eigenvectors. If A is symmetric, inv(V)=t(V). If A is asymmetric, there emerge difficulties and variants - how and when to compute V. SPSS MATRIX (being so old) unfortunately is missing a function for that. Singular-value problem is A = U*D*t(V), where A can be of any shape. D is the diagonal matrix with singular values. Note that there are two types of eigenvectors - left U and right V. Only when A is square symmetric positive semidefinite, the decomposition becomes equivalent to eigendecomposition (then, U=V, eigenvalues = singular values): for example, you can do PCA analysis either way. So, (the missing) EIGEN for a square asymmetric matrix is not the same as SDV of it. Below is the the code of eigendecomposition by QR algorithm (in its simplest, not practically efficient way). It is for symmetric matrix A and thus gives the results of CALL EIGEN(A,V,D). It can process asymmetric A as well, but V will be wrong then; as for D (diagonal) it might be correct then (but I'm not sure if always correct: I tried just 2 asymmetric matrices, it were correct). set mxloops 100. matrix. COMP A= {0.2273, -0.0852; -0.1930,0.1794}. comp q_= 1. loop it= 1 to 100. -comp q= gsch(a). -comp r= t(q)*a. -comp a= r*q. -comp q_= q_*q. end loop. print a /title 'Eigenvalues on the diagonal'. print q_ /title 'Eigenvectors'. end matrix. 21.11.2013 1:42, David Marso пишет:
Kirill, Please enlighten the class as to how an SVD is NOT the same as an eigendecomposition. In my example Q are eigenvalues, U and V are orthonormal . If one does an SVD of a symmetrical matrix the results are identical to EIGEN. |
In reply to this post by David Marso
Correction a lapse:
"If A is symmetric, inv(V)=t(V)." Should read "If A is positive semidefinite, inv(V)=t(V)." Also to say: if A is asymmetric, its eigenvectors V isn't orthogonal: t(V)*V won't be identity matrix. |
Administrator
|
In reply to this post by Kirill Orlov
Thanks for the elaboration!
I did a little mod of your code and found something interesting. First I changed it to stop when the iterations converged rather than 100. OTOH: When experimenting with an arbitrary matrix it failed to converge even after 100000 iterations. Probably something bizarre about the matrix itself? Thoughts? -- set mxloops 100000. MATRIX. COMPUTE epsilon= 1E-18. COMPUTE A= {0.2273 , -0.0852,.2345,.2345; -0.1930 ,0.1794,.24567,.12342; .378 ,.2783 ,.7897,.3454; .238934 ,.234675,.1234,.4567}. CALL SVD(A,X,Y,Z). PRINT A. PRINT X. PRINT Y. PRINT Z. COMPUTE q_= 1. COMPUTE solution={ a, a, a}. LOOP it= 1 to 100000. + DO IF (it GT 1). + COMPUTE solution={ a, q, q_ }. + END IF. + COMPUTE q= gsch(a). + COMPUTE a= t(q)*a*q. + COMPUTE q_= q_*q. + COMPUTE delta=MSUM (SSCP(ABS({ a, q, q_ })-ABS(solution))). END LOOP IF (delta LT epsilon). PRINT it . PRINT DELTA /FORMAT "F20.18". PRINT a /title 'Eigenvalues on the diagonal'. PRINT q_ /title 'Eigenvectors'. END MATRIX.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
David, as I've said, this was the code for symmetric matrix, your
matrix is not symmetric. Second, not every asymmetric matric can
have eigenvectors. e.g.
http://en.wikipedia.org/wiki/Defective_matrix
21.11.2013 18:44, David Marso пишет:
Thanks for the elaboration! I did a little mod of your code and found something interesting. First I changed it to stop when the iterations converged rather than 100. OTOH: When experimenting with an arbitrary matrix it failed to converge even after 100000 iterations. Probably something bizarre about the matrix itself? Thoughts? -- set mxloops 100000. MATRIX. COMPUTE epsilon= 1E-18. COMPUTE A= {0.2273 , -0.0852,.2345,.2345; -0.1930 ,0.1794,.24567,.12342; .378 ,.2783 ,.7897,.3454; .238934 ,.234675,.1234,.4567}. CALL SVD(A,X,Y,Z). PRINT A. PRINT X. PRINT Y. PRINT Z. COMPUTE q_= 1. COMPUTE solution={ a, a, a}. LOOP it= 1 to 100000. + DO IF (it GT 1). + COMPUTE solution={ a, q, q_ }. + END IF. + COMPUTE q= gsch(a). + COMPUTE a= t(q)*a*q. + COMPUTE q_= q_*q. + COMPUTE delta=MSUM (SSCP(ABS({ a, q, q_ })-ABS(solution))). END LOOP IF (delta LT epsilon). PRINT it . PRINT DELTA /FORMAT "F20.18". PRINT a /title 'Eigenvalues on the diagonal'. PRINT q_ /title 'Eigenvectors'. END MATRIX. Kirill Orlov wroteKirill, Please enlighten the class as to how an SVD is NOT the same as an eigendecomposition. In my example Q are eigenvalues, U and V are orthonormal . If one does an SVD of a symmetrical matrix the results are identical to EIGEN. * Eigenvalue* problem is A = V*D*inv(V), where A is square decomposed matrix, D is diagonal matrix with eigenvalues , V is the eigenvectors. Note - there is only one type of eigenvectors. If A is symmetric, inv(V)=t(V). If A is /asymmetric/, there emerge difficulties and variants - how and when to compute V. SPSS MATRIX (being so old) unfortunately is missing a function for that. *Singular-value* problem is A = U*D*t(V), where A can be of any shape. D is the diagonal matrix with singular values. Note that there are two types of eigenvectors - left U and right V. Only when A is *square symmetric positive semidefinite*, the decomposition becomes equivalent to eigendecomposition (then, U=V, eigenvalues = singular values): for example, you can do PCA analysis either way. So, (the missing) EIGEN for a square asymmetric matrix is not the same as SDV of it. Below is the the code of eigendecomposition by QR algorithm (in its simplest, not practically efficient way). It is for symmetric matrix A and thus gives the results of CALL EIGEN(A,V,D). It can process asymmetric A as well, but V will be *wrong *then; as for D (diagonal) it *might *be correct then (but I'm /not /sure if always correct: I tried just 2 asymmetric matrices, it were correct). set mxloops 100. matrix. COMP A= {0.2273, -0.0852; -0.1930,0.1794}. comp q_= 1. loop it= 1 to 100. -comp q= gsch(a). -comp r= t(q)*a. -comp a= r*q. -comp q_= q_*q. end loop. print a /title 'Eigenvalues on the diagonal'. print q_ /title 'Eigenvectors'. end matrix. 21.11.2013 1:42, David Marso ?????:Kirill, Please enlighten the class as to how an SVD is NOT the same as an eigendecomposition. In my example Q are eigenvalues, U and V are orthonormal . If one does an SVD of a symmetrical matrix the results are identical to EIGEN.----- Please reply to the list and not to my personal email. Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/spss-sYntax-to-get-eigenvalues-tp5723185p5723225.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |