BookmarkSubscribeRSS Feed
thanoon
Calcite | Level 5

hi

i need your help to simulate two different sample from multivariate dichotomous variables by using sas/iml and the program below for 1 sample how can i circulate for two samples.

thanks in advance

%include "C:\Users\hp\Desktop\RandMVBinary.sas";

proc iml;

load module=_all_;                     /* load the modules */

p = {0.25  0.75  0.5  0.25  0.30  0.10  0.30  0.55  0.25 0.65};       /* expected values of the X   */

Delta = {1     0.15  0.2   0.175  0.15  0.125 0.1   0.075 0.05  0.025,

        0.15  1     0.225 0.15   0.175 0.075 0.125 0.1   0.075 0.05 ,

        0.2   0.225 1     0.225  0.2   0.15  0.15  0.125 0.1   0.075,

        0.175 0.15  0.225 1      0.225 0.2   0.175 0.15  0.125 0.1  ,

        0.15  0.175 0.2   0.225  1     0.225 0.2   0.175 0.15  0.125,

        0.125 0.075 0.15   0.2   0.225 1     0.225 0.125 0.175 0.1  ,

        0.1   0.125 0.15   0.175 0.2   0.225 1     0.225 0.2   0.175,

        0.075 0.1   0.125 0.15   0.175 0.125 0.225 1     0.225 0.2  ,

        0.05  0.075 0.1   0.125  0.15  0.175 0.2   0.225 1     0.2  ,

        0.025 0.05  0.075 0.1    0.125 0.1   0.175 0.2   0.2   1    };

X = RandMVBinary(1000, p, Delta);

/* compare sample estimates to parameters */

print p, Delta;

create MVbinary from X;  append from X;  close MVB;

quit;

8 REPLIES 8
Rick_SAS
SAS Super FREQ

Y = RandMVBinary(1000, p, Delta);

thanoon
Calcite | Level 5

thanks alot dr. rick

please where can i put this y = RandMVBinary(1000, p, Delta); because i have x = RandMVBinary(1000, p, Delta);     in my program , and after putting this command y = RandMVBinary(1000, p, Delta); the program will be

%include "C:\Users\hp\Desktop\RandMVBinary.sas";

proc iml;

load module=_all_;                     /* load the modules */

p = {0.25  0.75  0.5  0.25  0.30  0.10  0.30  0.55  0.25 0.65};       /* expected values of the X   */

Delta = {1     0.15  0.2   0.175  0.15  0.125 0.1   0.075 0.05  0.025,

        0.15  1     0.225 0.15   0.175 0.075 0.125 0.1   0.075 0.05 ,

        0.2   0.225 1     0.225  0.2   0.15  0.15  0.125 0.1   0.075,

        0.175 0.15  0.225 1      0.225 0.2   0.175 0.15  0.125 0.1  ,

        0.15  0.175 0.2   0.225  1     0.225 0.2   0.175 0.15  0.125,

        0.125 0.075 0.15   0.2   0.225 1     0.225 0.125 0.175 0.1  ,

        0.1   0.125 0.15   0.175 0.2   0.225 1     0.225 0.2   0.175,

        0.075 0.1   0.125 0.15   0.175 0.125 0.225 1     0.225 0.2  ,

        0.05  0.075 0.1   0.125  0.15  0.175 0.2   0.225 1     0.2  ,

        0.025 0.05  0.075 0.1    0.125 0.1   0.175 0.2   0.2   1    };

X = RandMVBinary(1000, p, Delta);

y = RandMVBinary(1000, p, Delta);

/* compare sample estimates to parameters */

print p, Delta;

create MVbinary from X;  append from X;  close MVB;

quit;

i get on just one sample i want 2 samples, you mean i must repeat the program one to x and another to y?

thanks in advance

THANOON

thanoon
Calcite | Level 5

i think i must repeat the program one time for x and another time for y too get on different samples.

thanks alot dr. rick

Rick_SAS
SAS Super FREQ

You don't need two programs. Assign Y after you have assigned X within the same program.

thanoon
Calcite | Level 5

thank you so much i want to apply same method on mvordinal with two samples but i got on same results for X AND Y.how can i solve this problem.

many thanks

thanoon
Calcite | Level 5

thanks alot dr.rick i solve it . i want to ask you when i applied same equation X and Y in mvordinal i got on same results why?

many thanks

Rick_SAS
SAS Super FREQ

You should not get the same answer if you compute both in a single PROC IML program.

If you run the same program twice, you will get the same answer because the random number seed is the same.

thanoon
Calcite | Level 5

So I must change the random number seed for the second program.

Thanks alot

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 8 replies
  • 1615 views
  • 0 likes
  • 2 in conversation