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-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 739 views
  • 0 likes
  • 3 in conversation