turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-31-2011 07:06 PM

Is the below code correct in order to generate 3 variables from multivariate normal distribution?

Proc iml;

Call randseed(1);

n= 50;

mean ={0 0 0};

corr= {1 0.7 0.6, 0.7 1 0.8, 0.6 0.8 1};

sigma= {2 3 4};

cov = corr # (sigma * t(sigma));

X = randnormal (n, mean, cov);

Print X;

Proc iml;

Call randseed(1);

n= 50;

mean ={0 0 0};

corr= {1 0.7 0.6, 0.7 1 0.8, 0.6 0.8 1};

sigma= {2 3 4};

cov = corr # (sigma * t(sigma));

X = randnormal (n, mean, cov);

Print X;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to aya123

04-01-2011 08:11 AM

No. You want

cov = corr # (t(sigma) * sigma);

which is a matrix, whereas sigma * t(sigma) is a scalar.

This is Method #3 in the following blog post, which describes how to convert between correlation and covariance matrices:

http://blogs.sas.com/iml/index.php?/archives/49-Converting-Between-Correlation-and-Covariance-Matric...

cov = corr # (t(sigma) * sigma);

which is a matrix, whereas sigma * t(sigma) is a scalar.

This is Method #3 in the following blog post, which describes how to convert between correlation and covariance matrices:

http://blogs.sas.com/iml/index.php?/archives/49-Converting-Between-Correlation-and-Covariance-Matric...

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

02-25-2015 12:58 AM

Thanks Rick. I have a question about generating multivariate data. I just started learning simulation and I want to generate multivariate data that are correlated, say .60, but with a skewed distribution. How I thought about doing this is: first, generate the correlated data from a normal distribution (mean=0, and variance=1), and then second, transform it into a chi-square distribution (with df=3 that reflects a skewness=1.63 and a kurtosis=4). I know how to do the first step, but I'm stuck with the second step on how to do it. In the first place, is it even right to do the second step (i.e., transform it into a chi-square distribution?). If not, is there a better way to do it?

Thanks,

Ariel

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ayecon0325

02-25-2015 06:07 AM

Generating correlated MV data is a huge topic. I discuss the best techniques (and provide SAS code to implement them) in Chapters 8, 9, and 16 of my book *Simulating Data with SAS. *