BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
madix
Obsidian | Level 7

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
Rick_SAS
SAS Super FREQ

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} );

View solution in original post

6 REPLIES 6
Ksharp
Super User

calling @Rick_SAS

Ksharp
Super User
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;
Rick_SAS
SAS Super FREQ

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").

madix
Obsidian | Level 7

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 :mean.PNG

How to use this parameters into your code?

 

Thanks a lot for the quick answer

madix
Obsidian | Level 7

This is the only parameter that I have btw. I don't have the cov matrix. I just have the mean and the std for each cordonate of the vector.

Rick_SAS
SAS Super FREQ

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} );

sas-innovate-2024.png

Available on demand!

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

 

Register now!

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.

Discussion stats
  • 6 replies
  • 1574 views
  • 6 likes
  • 3 in conversation