Statistical programming, matrix languages, and more

simulation two different samples from multivariate dichotomous variables

Reply
Contributor
Posts: 74

simulation two different samples from multivariate dichotomous variables

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;

SAS Super FREQ
Posts: 3,233

Re: simulation two different samples from multivariate dichotomous variables

Y = RandMVBinary(1000, p, Delta);

Contributor
Posts: 74

Re: simulation two different samples from multivariate dichotomous variables

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

Contributor
Posts: 74

Re: simulation two different samples from multivariate dichotomous variables

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

SAS Super FREQ
Posts: 3,233

Re: simulation two different samples from multivariate dichotomous variables

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

Contributor
Posts: 74

Re: simulation two different samples from multivariate dichotomous variables

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

Contributor
Posts: 74

Re: simulation two different samples from multivariate dichotomous variables

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

SAS Super FREQ
Posts: 3,233

Re: simulation two different samples from multivariate dichotomous variables

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.

Contributor
Posts: 74

Re: simulation two different samples from multivariate dichotomous variables

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

Thanks alot

Post a Question
Discussion Stats
  • 8 replies
  • 583 views
  • 0 likes
  • 2 in conversation