BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
JOADUTWUM
Obsidian | Level 7
I used UN@AR(1) correlation structure for a spatiotemporal dataset in Proc Mixed. How can I get the spatiotemporal correlation (the Kronecker product of the two correlations)? Thank you.
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

To create an AR(1) matrix from the estimate, rho, see the first section in "Fast simulation of multivariate normal data with an AR(1) correlation structure."

 

Let's suppose both matrices are 3x3, although they can be any square dimensions. The following program computes the Kronecker product of an AR(1) correlation matrix with rho=0.8 and a unstructured matrix with estimates UN[1,2]=0.63, UN[1,3]=0.12, and UN[2,3]=0.34:

proc iml;
/* return p x p matrix whose (i,j)th element is rho^|i - j| 
See https://blogs.sas.com/content/iml/2018/10/03/ar1-cholesky-root-simulation.html */
start AR1Corr(rho, p); 
   return rho##distance(T(1:p), T(1:p), "L1");
finish;
 
/* test on a matrix with rho = 0.8 */
rho = 0.8;  p = 3;
AR1 = AR1Corr(rho, p);

UN = {1    0.63 0.12,
      0.63 1    0.34,
      0.12 0.34 1   };

K = UN@AR1;
print UN, AR1, K;

View solution in original post

3 REPLIES 3
Ksharp
Super User

Do you have SAS/IML ?

Maybe @Rick_SAS  could give you a hand.

JOADUTWUM
Obsidian | Level 7
Yes I do.
Rick_SAS
SAS Super FREQ

To create an AR(1) matrix from the estimate, rho, see the first section in "Fast simulation of multivariate normal data with an AR(1) correlation structure."

 

Let's suppose both matrices are 3x3, although they can be any square dimensions. The following program computes the Kronecker product of an AR(1) correlation matrix with rho=0.8 and a unstructured matrix with estimates UN[1,2]=0.63, UN[1,3]=0.12, and UN[2,3]=0.34:

proc iml;
/* return p x p matrix whose (i,j)th element is rho^|i - j| 
See https://blogs.sas.com/content/iml/2018/10/03/ar1-cholesky-root-simulation.html */
start AR1Corr(rho, p); 
   return rho##distance(T(1:p), T(1:p), "L1");
finish;
 
/* test on a matrix with rho = 0.8 */
rho = 0.8;  p = 3;
AR1 = AR1Corr(rho, p);

UN = {1    0.63 0.12,
      0.63 1    0.34,
      0.12 0.34 1   };

K = UN@AR1;
print UN, AR1, K;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 626 views
  • 2 likes
  • 3 in conversation