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

Dr. Wicklin's text provides significant support for simulating data from correlated multivariate distributions.  However, his text does not provide code for Simulating data from Correlated Multivariate Uniform Distributions.  Can anyone provide some example code?

For example, could I simply change the RANNOR to RANUNI in the below code?

data MVN (type = CORR); _TYPE_='CORR';

  set bhf.R;

run;

proc factor N=19 OUTSTAT=FACOUT;

run;

DATA PATTERN;

  SET FACOUT;

  IF _TYPE_='PATTERN';

  DROP _TYPE_ _NAME_;

RUN;

PROC IML;

  USE PATTERN;

  READ ALL VAR _NUM_ INTO F;

  F=F`;

  PRINT f;

DATA = RANNOR(J(10000,19,0));

DATA = DATA`;

  Z = F*DATA;

  Z = Z`;

  X1=Z[,1]*0.418378 + 0.01284361;

  X2=Z[,2]*0.418378 + 0.06569127;

  X3=Z[,3]*0.418378 + 0.02904674;

  X4=Z[,4]*0.418378 + 0.01284361;

  X5=Z[,5]*0.418378 + 0.02904674;

  X6=Z[,6]*0.418378 + 0.09878997;

  X7=Z[,7]*0.418378 + 0.02904674;

  X8=Z[,8]*0.418378 + 0.043682;

  X9=Z[,9]*0.418378 + 0.06569127;

  X10=Z[,10]*0.418378 + 0.043682;

  X11=Z[,11]*0.418378 + 0.01931489;

  X12=Z[,12]*0.418378 + 0.02904674;

  X13=Z[,13]*0.418378 + 0.02904674;

  X14=Z[,14]*0.418378 + 0.0437;

  X15=Z[,15]*0.418378 + 0.0657;

  X16=Z[,16]*0.418378 + 0.02904674;

  X17=Z[,17]*0.418378 + 0.043682;

  X18=Z[,18]*0.418378 + 0.01931489;

  X19=Z[,19]*0.418378 + 0.02904674;

  Z=X1||X2||X3||X4||X5||X6||X7||X8||X9||X10||X11||X12

  ||X13||X14||X15||X16||X17||X18||X19;

  CREATE A FROM Z [COLNAME={X1 X2 X3 X4 X5 X6 X7 X8 X9

  X10 X11 X12 X13 X14 X15 X16 X17 X18 X19}];

  APPEND FROM Z;

PROC MEANS DATA=A N MEAN STD SKEWNESS KURTOSIS;

  VAR X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15

  X16 X17 X18 X19;

PROC CORR DATA=A NOSIMPLE;

  VAR X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15

  X16 X17 X18 X19;

RUN;

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

A correlated MV uniform distribution is called a copula. See p. 164-173.

View solution in original post

5 REPLIES 5
Rick_SAS
SAS Super FREQ

A correlated MV uniform distribution is called a copula. See p. 164-173.

bhfield
Calcite | Level 5

Dr. Wicklin - I think this approach may work.....you might recognize most of it!

I generated univariate uniform random variates with specified means.  Then I used the approach you described in your text, namely, the Iman-Conover method to generate multivariate data with the specified marginals I just mentioned and a desired correlation structure.  (I assumed the Pearson correlation was close enough to the Spearman rank correlation.)

I think it may be good enough.....

In the mean time, what is the difference between using the Iman-Conover method and any of the copula approaches? It seems like they are accomplishing the same task....

Thanks again for your support as I learn a new subject.


Brian

Rick_SAS
SAS Super FREQ

Yes. The Iman-Conover method uses ideas that are similar to copulas, which is why I placed it just before the section on copulas. I also begin the section on copulas with the sentences "Each of the previous sections describes.... That is exactly what a mathematical copula does."

You will discover that special cases of the copula have been (re)discovered many times in the literature.

Rick_SAS
SAS Super FREQ

BTW, there is an errata for the program on p. 162.  About 6 lines from the bottom of the program, the statement in the book are

y = X[,i];

call sort(y);

X[,i] = y[rank];

The correct statements are

tmp = X[,i];

call sort(tmp);

X[,i] = tmp[rank];

bhfield
Calcite | Level 5

Thanks Dr. Wicklin. I accessed the code from your author's page, so it appears that code was corrected there.  Thanks for the heads up.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1460 views
  • 1 like
  • 2 in conversation