turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-18-2014 08:04 AM

Dear all,

I need to find the eigenvalues of 3*3 matrix.

I get 3*2 matrix as an answer for eigenvalues. (The second column is zero's)

How can it be? Why I don't get a vector?

Thank you,

Orit

I enclose the code:

proc iml;

m={0.145373 0.018866 -0.000675,

-0.261593 1.0143407 0.0145192,

1.4433602 -0.116446 0.9282068};

eigm=eigval(m);

print eigm;

THE ANSWER:

0.9882288 | 0 |

0.9467909 | 0 |

0.1529008 | 0 |

Accepted Solutions

Solution

09-18-2014
09:55 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 09:55 AM

Try something like:

x={2 2, -1 0};

print (eigval(x));

A non-symmetric matrix of reals may have complex eigenvalues, so the second column is for the complex part.

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 09:37 AM

Not sure, how proc iml process this. You can try proc princom to get eigen vectors.

data have;

input m1 m2 m3;

datalines;

0.145373 0.018866 -0.000675

-0.261593 1.0143407 0.0145192

1.4433602 -0.116446 0.9282068

;

proc princom data=have;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

09-18-2014 10:50 AM

Thank you for your reply!!

The results between SAS/IML and proc princom are really different.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 11:04 AM

Can you please share eigen values and eigen vectors obtained through proc iml?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

09-18-2014 11:31 AM

The first column is eigenvalue through proc princom

1 | 2.55176487 | 2.10352974 | 0.8506 | 0.8506 |
---|---|---|---|---|

2 | 0.44823513 | 0.44823513 | 0.1494 | 1.0000 |

3 | 0.00000000 | 0.0000 | 1.0000 |

proc iml

0.9882288 | 0 |

0.9467909 | 0 |

0.1529008 | 0 |

As you can see the results are really different,

The proc iml results are more logical

Thanks,

Orit

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 12:25 PM

Hi Dr. Rick,

Thanks for your feedback on this. Just to understand it in a better way have a couple of questions. When we use princom it calculates eigen values either using correlation matrix or cov matrix. So if we execute analysis given below, calculations will be done based on symmetric cov matrix . Why we need to feed princomp a cov matrix, if it can be calculated as part of proc princom?

Regards,

Naeem

data have;

input m1 m2 m3;

datalines;

0.145373 0.018866 -0.000675

-0.261593 1.0143407 0.0145192

1.4433602 -0.116446 0.9282068

;

proc princomp data=have cov;

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

09-18-2014 01:37 PM

As I said, by default PROC PRINCOMP thinks that the data in the DATA= option are observations. In your example, it thinks that you are specifying 3 variables, each with three observations. Call that data X. The covariance matrix for X is formed as follows:

C = X - mean(X); /* center the data */

S = (C` * C) / (nrow(X)-1); /* assume no missing values */

In other words, the eigenvalues that are reported for your example are for the covariance matrix S, which is the crossproduct of the centered data, divided by n-1. The IML code is reporting the eigenvalues for X; the PRINCOMP code is reporting the eigenvalues for S.

In my earlier post, I showed that you can specify TYPE=COV as a data set option in order to make PROC PRINCOMP understand that the DATA= data is a covariance matrix, not raw observations.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

09-18-2014 01:55 PM

Thanks so much Dr. Rick. I was just mixing observations with cov matrix.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 11:28 AM

PROC PRINCOMP thinks that the values in the HAVE data set are observations. PROC PRINCOMP can compute the eigenvalues and eigenvector of SYMMETRIC matrices. However, you have to use a TYPE=COV data set and you have to use the COV option on the PROC PRINCOMP stmt. For unsymmetric matrices, PROC PRINCOMP will give you an error.

The correct way to do it (for SYMMETRIC matrices) is as follows:

data have(type=cov); /* leave off a lot of the TYPE=COV data for simplicity */

_type_='COV';

input m1-m3;

datalines;

0.145373 -0.261593 1.4433602

-0.261593 1.0143407 -0.116446

1.4433602 -0.116446 0.9282068

;

ods select eigenvalues eigenvectors;

proc princomp data=have(TYPE=COV) cov;

run;

proc iml;

use have; read all var _NUM_ into M; close;

eigm=eigval(m);

print eigm;

Solution

09-18-2014
09:55 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 09:55 AM

Try something like:

x={2 2, -1 0};

print (eigval(x));

A non-symmetric matrix of reals may have complex eigenvalues, so the second column is for the complex part.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to oriti

09-18-2014 10:31 AM

For symmetric matrices, EIGVAL returns a column vector. For nonsymmetric matrices, EIGVAL returns an N x 2 matrix, where the first column is the real part and the second column is the imaginary part.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

09-18-2014 10:56 AM

Thank you Rick!