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
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} );
calling @Rick_SAS
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;
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").
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
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.
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} );
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!
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.