BookmarkSubscribeRSS Feed
bhfield
Calcite | Level 5

I am replicating Rick's Covariance / Correlation Cholesky transformation within Proc IML as follows:

proc iml;

  D = { 1 2 3,

  2 4 3,

  3 3 9};

  X = root(D)`*root(D);

  print D;

  print X;

run;

Interestingly, X does not equal D.  I am wondering if this is due to D not being Positive Definite or, in other words, Det(D) <0.  The code runs without any indication of a problem.....had I not printed X, I would have never known that that Root(D)`*Root(D) would not equal D.

Any thoughts on why this is the case?

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Interesting. I've never seen this behavior before. The correct behavior would be for the ROOT function to report an error in the log:

ERROR: (execution) Matrix should be positive definite

If I were to guess, I'd say that the exact integer values are causing a numerical problem in the ROOT function such that the ROOT function does not report the error. In the following code I perturb an element by a tiny amount and the ROOT function correctly reports that the matrix is not PD:

D[1] = D[1] + 1e-8;

G = root(D);

I will enter a bug report at SAS so that someone can look into this situation further.

bhfield
Calcite | Level 5

Thanks Dr. Wicklin.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 824 views
  • 1 like
  • 2 in conversation