BookmarkSubscribeRSS Feed
JennyQLi
Calcite | Level 5


I'm trying to simulate data from a multivariate normal distribution with mean=MU and variance=MVNCOV:

For example, if we want to run 1000 simulations from a multivariate normal with MU={6.3 1.8 3.7} and

MVNCOV={2, 3, 1,

                 3, 8, 5,

                 1, 5, 4}

Are the following codes correct? Thanks!

proc iml;

  nobs=1000;

  MU={6.3 1.8 3.7);

  MVNCOV={2 3 1,

                   3 8 5,

                   1 5 4};

  MVS=ROOT(MVNCOV);

  RandSeed=floor(RANUNI(round(time(),16.0))*10000000); /* simulate random seed from system time */

  x=J(nobs,1,1)*MU + NORMAL(J(nobs,3,RandSeed))*MVS;

  create _simparm0_ from x(| COLNAME={P1 P2 P3} |); append from x;

quit;

run;

2 REPLIES 2
PGStats
Opal | Level 21

I can't help you with proc IML. But you might want to look at proc SIMNORMAL. Its sole purpose is the generation of correlated normal random numbers.

PG

PG

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 1421 views
  • 6 likes
  • 3 in conversation