## Bivariate Table distribution

Regular Contributor
Posts: 181

# Bivariate Table distribution

Hello all,

I would like to simulate data of a bivariate "table" distribution.

I want to generate a vector of values (0,1,2,3,4,5) with probabilities (p(0), p(1), p(2), p(3), p(4), p(5)). Then I want to generate another such vector, with a correlation of let's say 0.8 to the first vector.

How do I do that ?

Thank you in advance.

SAS Super FREQ
Posts: 4,175

## Re: Bivariate Table distribution

Although your message sounds like you might be wanting to use conditional probability, I suspect that you are trying to generate two vectors jointly from a correlated multivariate ordinal distribution.   This is described in Section 9.4 of Simulating Data with SAS, and further described in the Appendix B. Using the modules described in the book, the code looks like this:

/* read in programs from Simulating Data with SAS */
%include "C:\Downloads\Wicklin2013\RandMVOrd.sas";
proc iml;
load module=_all_;

/* define the probabilities of X1 and X2 */
/*   X1   X2 */
P = {0.1  0.1,    /* P(0) */
0.2  0.2,    /* P(1) */
0.2  0.2,    /* P(2) */
0.2  0.2,    /* P(3) */
0.2  0.2,    /* P(4) */
0.1  0.1 };  /* P(5) */
/* define the correlation between X1 and X2 */
Delta = {1   0.8,
0.8 1.0 };

/* generate two vectors of 100 observations */
call randseed(54321);
X = RandMVOrdinal(100, P, Delta);

/* test the process by computing sample correlation */
corr = corr(X);
print corr;

corr

1 0.7709831

0.7709831         1

Discussion stats
• 1 reply
• 418 views
• 0 likes
• 2 in conversation