BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASaholic629
Fluorite | Level 6

I am able to create random correlated standard normal draws using PROC IML and feeding it a correlation matrix and a vector of means=0 (see the code below)

 

*Create Lower Triangular Correlation Matrix;
DATA Have_Matrix;
INPUT C1 C2 C3 C4;
DATALINES;
1	.7	.2	0
.7	1	.4	.5
.2	.4	1	.3
0	.5	.3	1
;RUN;

*Create a vector of Means=0;
DATA Have_Means (Drop=i);
DO i = 1 TO 4;
	Mean = 0;
	OUTPUT;
END;
RUN;

*Create the Correlated Random Draws;
PROC IML;
USE Have_Matrix;
READ ALL VAR _NUM_ INTO CovMatrix;	*Symmetric Covariance Matrix;
USE Have_Means;
READ all VAR _NUM_ INTO Mean;
N = 1000;							*sample size;
X = RandNormal(N, Mean, CovMatrix);	*1,000 x 4 Correlated Std Normal Draws;
CREATE Want FROM X; APPEND FROM X; CLOSE Want;
QUIT;

How do I do this using a Student's T distribution? (I believe the above code defaults to Gaussian? I could be wrong about that so please correct me if I am misinterpreting)

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Use the RANDMVT function to generate random observations from a multivariate t distribution.

View solution in original post

2 REPLIES 2
Ksharp
Super User

I remembered there is a RAND function to get it .

Better post it at IML forum . @Rick_SAS  is there.

Rick_SAS
SAS Super FREQ

Use the RANDMVT function to generate random observations from a multivariate t distribution.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 1320 views
  • 0 likes
  • 3 in conversation