oliyiyi
sas/iml哪一个函数是求矩阵的秩,rank和rankte都不行,查了半天reference居然没有找到!
rtist
据我所知,矩阵求秩还是一个尚未解决的难题。
rtist
如果一定需要用计算机判断的话,可以从echelon、svd等等函数中判断出来。但是如果有其他条件可用而不是任意一个方阵,尽可能用上其他条件。
看看别人还有没有更好的办法吧。
oliyiyi
谢谢rtist!
oliyiyi
不对啊,怎么eviews中都有@rank的函数啊,难道sas中没有这个函数?
rtist
能提供着个函数不难,因为光从数学上讲,随便找个学生都会求秩,
难的是保证这个函数能在任何情况下都正确工作。
oliyiyi
我找到答案了就是用:
round(trace(ginv(a)*a))
呵呵!
rtist
Yes. That's one way that works for "most" a, but not "all" a.
oliyiyi
why? 矩阵广义逆一般来说都存在吧!
rtist
Mathematically, you are right. But computationally, not every matrix can be calculated properly. That's why this is hard.
oliyiyi
sas本省的很多函数都不可能在任何情况下都正常工作(比如说阶乘),这不应该作为sas为什么没有求矩阵秩的函数的理由吧。(毕竟eview都有啊!)说实在的,现在觉得sas/iml 在几种矩阵语言里真得没有什么优势。
rtist
:D
I'm never a supporter for SAS anyway~~
Factorial problem is just on the other end, compared with rank or inversion problems. Theoretically, factorials are much easier to solve, I guess. You might find a (long) zz post in R board interesting.