Statistical programming, matrix languages, and more

Simulation from a multivariate normal distribution

Reply
N/A
Posts: 1

Simulation from a multivariate normal distribution


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;

Respected Advisor
Posts: 4,606

Re: Simulation from a multivariate normal distribution

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 Super FREQ
Posts: 3,225

Re: Simulation from a multivariate normal distribution

Post a Question
Discussion Stats
  • 2 replies
  • 517 views
  • 6 likes
  • 3 in conversation