<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc IML Matrix products incorrect? in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619990#M4961</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/308872"&gt;@cwigtil&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;I’m wondering if Proc IML with the EIGEN call has difficulty with calculating eigenvalues for such large matrices? The eigenvalues seem accurate because the largest ones for the 3000 x 3000 product matrices match those of the 55 x 55 matrices.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is my understanding that the eigenvalues of x' * x should be equal to the eigenvalues of x * x'.&lt;/P&gt;</description>
    <pubDate>Sat, 25 Jan 2020 12:03:35 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-01-25T12:03:35Z</dc:date>
    <item>
      <title>Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619971#M4959</link>
      <description>I am working with a 3000 x 55 matrix with cell values of either 0 or 1, which I am transposing &amp;amp; mirroring the contents (0 becomes 1 &amp;amp; vice versa), then multiplying to obtain four product matrices. Mathematically, this procedure should yield a single Perron root across all 4 product matrices, but I am not obtaining this result. I double-checked my code for accuracy.&lt;BR /&gt;&lt;BR /&gt;I’m wondering if Proc IML with the EIGEN call has difficulty with calculating eigenvalues for such large matrices? The eigenvalues seem accurate because the largest ones for the 3000 x 3000 product matrices match those of the 55 x 55 matrices.</description>
      <pubDate>Sat, 25 Jan 2020 01:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619971#M4959</guid>
      <dc:creator>cwigtil</dc:creator>
      <dc:date>2020-01-25T01:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619986#M4960</link>
      <description>&lt;P&gt;Could you provide an example of your computations? Since eigenvalues only apply to square matrices, I am not sure what you are doing with the (x x p) matrix. It sounds like you are comparing eigenvalues of X`X and XX`, but I don't understand what the other two matrices are. For example, here is one possible computation. Am I close?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
X = {1 0,
     0 1,
     1 0,
     0 1};
notX = ^X;
A1 = X`*X;
A2 = X*X`;
A3 = notX`*notX;
A4 = notX*notX`;

v1 = eigval(A1);
v2 = eigval(A2);
v3 = eigval(A3);
v4 = eigval(A4);
print v1 v3, v2 v4;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, please specify which version of SAS you are running:&lt;/P&gt;
&lt;P&gt;%put &amp;amp;SYSVLONG4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 11:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619986#M4960</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-25T11:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619990#M4961</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/308872"&gt;@cwigtil&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;I’m wondering if Proc IML with the EIGEN call has difficulty with calculating eigenvalues for such large matrices? The eigenvalues seem accurate because the largest ones for the 3000 x 3000 product matrices match those of the 55 x 55 matrices.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is my understanding that the eigenvalues of x' * x should be equal to the eigenvalues of x * x'.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 12:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619990#M4961</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-25T12:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619991#M4962</link>
      <description>&lt;P&gt;The nonzero eigenvalues are the same, yes. But the 3000 x 3000 matrix is highly degenerate since it has at least (3000-55) zero eigenvalues.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 12:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619991#M4962</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-25T12:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619997#M4963</link>
      <description>&lt;P&gt;Thank you so much for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data are known and verified to only have values of 0 or 1 and to not have missing values, the original matrix (A) is "mirrored" (A') as its complement as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i=1 to 55;&lt;BR /&gt;&amp;nbsp; vara_p(i) = abs(vara(i)-1);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both original &amp;amp; complement are then transposed (B &amp;amp; B') &amp;amp; multiplied as A*B', A'*B, B*A', B'*A; regarding computation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;use a_orig;&lt;BR /&gt;read all var _num_ into y;&lt;BR /&gt;use b_transp;&lt;BR /&gt;read all var _num_ into i;&lt;BR /&gt;c = y * i;&lt;/P&gt;&lt;P&gt;create Out var {c};&lt;BR /&gt;append;&lt;BR /&gt;close Out;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similarly I made an i*y for the same two matrices, then calculated products for the other two matrices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output for the four product matrices were two 3,025-long &amp;amp; two 9,709,456-long outputs, each of which I recognized as the square of 55 &amp;amp; 3116, the dimensions of the respective product matrix, so I reconfigured each of those to create the square matrices via datasteps. I then made a dataset (e.g., c_prod) for the square product matrices:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;use c_prod;&lt;BR /&gt;read all var _num_ into C;&lt;BR /&gt;call eigen(val, rvec, C);&lt;BR /&gt;print val;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There should be a single Perron root across all four square product matrices, but unfortunately, that's not what I'm finding:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.psych.purdue.edu/~ehtibar/publications/DSDS.pdf" target="_blank"&gt;http://www.psych.purdue.edu/~ehtibar/publications/DSDS.pdf&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Annotation 2020-01-25 080445.png" style="width: 502px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35620i54E10AEC985D2B41/image-size/large?v=v2&amp;amp;px=999" role="button" title="Annotation 2020-01-25 080445.png" alt="Annotation 2020-01-25 080445.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS version:&amp;nbsp;9.04.01M5P09132017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take care,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;~Cliff&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 14:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/619997#M4963</guid>
      <dc:creator>cwigtil</dc:creator>
      <dc:date>2020-01-25T14:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620011#M4964</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The nonzero eigenvalues are the same, yes. &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's what I meant&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2020 17:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620011#M4964</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-25T17:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620191#M4965</link>
      <description>&lt;P&gt;Thank you for posting more information. It would be helpful if you could modify the following example to show what computations you are doing after you get the eigenvalues. How are you comparing the eigenvalues? What computations are you doing to determine if they are equal?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
A = {1 0 1,
     0 1 1,
     1 0 1,
     0 1 1,
     1 1 1,
     1 1 0,
     0 0 0};
B = ^A;

C1 = A*B`;
C2 = B*A`;   /* C2 = C1` so they have the same eigenvalues */
C3 = A`*B;
C4 = B`*A;   /* C4 = C3` so they have the same eigenvalues */

v1 = eigval(C1);
v2 = eigval(C2);
v3 = eigval(C3);
v4 = eigval(C4);
print v1 v2, v3 v4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A few observations that might help:&lt;/P&gt;
&lt;P&gt;1. C1 and C2 should have the same eigenvalues. Similarly, C3 ad C4 should have the same eigenvalues. However, these matrices do not have to be symmetric. For an unsymmetric matrix, the eigenvalues do not have to be real. Therefore, they are returned as a k x 2 matrix, where the first column contains the real part and the second contains the imaginary part (possibly 0) for each eigenvalue.&lt;/P&gt;
&lt;P&gt;2. Even though the matrices have the same theoretical eigenvalues, the C1 and C2 matrices will contain thousands of zero eigenvalues. A system that has many repeated eigenvalues is highly degenerate. Even in the best situation, the "zero eigenvalues" will likely be small values such as 1.234e-14. When you compare eigenvalues, make sure you do not compare these finite-precision results with 0 by using an exact comparison.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I look forward to seeing how you are comparing the eigenvalues.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 15:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620191#M4965</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-27T15:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620314#M4966</link>
      <description>&lt;P&gt;Thanks so much for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, I'm only checking that the largest real number eigenvalue of each product is the same (which is the Perron root), because this is what Double Skew-Dual Scaling should yield across all four product matrices. Because SAS lists these in descending order by default, I only need to check the largest real number eigenvalue at the top (unless I'm wrong?).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thinking about this problem, I may need to drop a variable which has only values of 1; I think this might create problems in the product matrices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 19:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620314#M4966</guid>
      <dc:creator>cwigtil</dc:creator>
      <dc:date>2020-01-27T19:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620317#M4967</link>
      <description>&lt;P&gt;It shouldn't matter if you have a constant column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2020 20:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/620317#M4967</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-27T20:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML Matrix products incorrect?</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/621345#M4968</link>
      <description>I re-did the code and got a consistent Perron root: hooray!</description>
      <pubDate>Fri, 31 Jan 2020 00:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-Matrix-products-incorrect/m-p/621345#M4968</guid>
      <dc:creator>cwigtil</dc:creator>
      <dc:date>2020-01-31T00:15:08Z</dc:date>
    </item>
  </channel>
</rss>

