Turn on suggestions

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

Showing results for

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 11-16-2011 07:15 PM
(1676 views)

Hi it's me again;)

I would like to loop the RANDNORMAL function using a random correlation matrix for a certain number of times. The results for each drawing should be added horizontally to the already existing ones.

*Example:*

*RANDNORMAL is used in combination with a random correlation matrix to create a 1000x100 matrix M of standard normal distributed variables with a specific correlation structure. The goal is to repeat the procedure 20 times. The results of each run should be merged together. The result would be a 1000x20000 matrix. Each 1000x100 block should have a specific correlation structure (determined by the correlation matrix which changes in every run). *

I hope you get the idea. I was wondering if you might know a way to loop the RANDNORMAL procedure in combination with a random correlation matrix....

THANKS A MILLION!!!

6 REPLIES 6

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

What have you tried so far?

The hard part here is generating the random correlation matrix. Not every random matrix is a correlation matrix, and the algorithms for generating a correlation matrix are sometimes complicated. How hard it is depends on the "specific correlation structure" that you mention. Some simple structures that are sometimes used in simulations are the "intraclass" correlation structure, the MA(1) correlation structure, and the AR(1) correlation structure.

It looks like you are trying to sample from a multivariate normal distribution in 10 dimensions (since you have 10x10=100 columns).

Do you know how to write a function that generates a random 10x10 correlation matrix with the specific structure?

Depending on what you're trying to do, it might take days or weeks write this function.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi Rick!

Once again I have to thank you for your quick response;)

To be honest, I have't spent much time on thinking about the generation of a random correlation matrix yet. However, since my last post I've figured out how to use macros to loop the entire process. So the random correlation matrix is next on my list.

Which of the structures you've mentioned would you prefer? So far I just thought about using uniformly distributed random numbers on the interval (-1,1), which I would use to create the correlation matrix.

I'm thankful for every comment...

THANK YOU!!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi!

I know it's a little bit off topic but maybe you could help me..I spent some more time thinking about the correlation matrix. Do you know a way in IML to extract a correlation matrix from another (larger) correlation matrix? In detail, I want to select certain variables from a pool of variables. While the correlation matrix of the entire pool has been already calculated the correlation matrix of the selected variables should be extracted from the pool correlation matrix.

Example:

The pool consists of 10 variables. The corresponding 10x10 correlation matrix has been already calculated.

Now I select three variables of the pool. How can I extract the 3x3 correlation matrix from the pool correlation matrix via IML?

THANK YOU!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

See pp. 31-32 of my book Statistical Programming with SAS/IML Software.Those pages are available as a FREE download.

To choose three random columns, use the RANCOMB function.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you so much, Rick!

I'm really thinking about getting your book;)

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It makes the perfect Christmas gift, although it is too big to fit in a stocking. 🙂

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

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.