Turn on suggestions

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

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- simulation

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

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

Posted 11-03-2017 03:45 AM
(1573 views)

Hello,

I am wondering how to simulate a gaussian vector with 3 random variable with proc IML in SAS, and to determine the covariance matrix of this vector.

If anyone could help,

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

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

From what you have said, I assume you want three independent Gaussian vectors. That is equivalent to a diagonal covariance matrix in the RANDNORMAL function. Based on your table, you would use

Mean = {0 0 0}; /* mean of population */

Cov = diag( {0.00264, 0.00286, 0.00590} );

6 REPLIES 6

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

calling @Rick_SAS

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

```
proc iml;
call randseed(1);
prob = {0.3,0.6,0.1};
NumTrials = 10;
N = 100;
x = RandMultinomial(N,NumTrials,prob);
SampleMean = mean(x);
SampleCov = cov(x);
print x,SampleMean, SampleCov ;
quit;
```

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

Use the RANDNORMAL function, as shown in the article "Sampling from the multivariate normal distribution." If you want the three components to be independent, specify the identity matrix (I(3)) as a parameter. For correlated data, specify the population covariance matrix. You can use the COV function on the simulated data to estimate the population covariance.

BTW, KSharp's program simulates multinomial data, which is not the same as multivariate normal ("Gaussian").

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

I have to put some mean and std that I have too in order to simulate them for each normal random variable. My parameters are the following :

How to use this parameters into your code?

Thanks a lot for the quick answer

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

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

From what you have said, I assume you want three independent Gaussian vectors. That is equivalent to a diagonal covariance matrix in the RANDNORMAL function. Based on your table, you would use

Mean = {0 0 0}; /* mean of population */

Cov = diag( {0.00264, 0.00286, 0.00590} );

**Available on demand!**

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

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.