*****************************************************;
* MVNGen.sas - Generate multivariate normal data *;
* E. Barry Moser, Dept Experimental Statistics, LSU *;
*****************************************************;
ODS HTML body= "MVNGen.html"
headtext="<title>Simulated Multivariate Normal Data</title>"
anchor="MVNGen";
Options PS=55 LS=80 PageNo=1 NoDate
FORMCHAR='|----|+|---+=|-/\<>*';
Title1 "Simulated Multivariate Normal Data";
Proc IML;
/*
* Set Printing Options:
* NOLOG -> Send output to Listing window if printing turned on.
* NOPRINT -> Suppress printing. Set to PRINT to get output.
*/
Reset NoLog NoPrint;
/*
* Specify random number seed
*/
Seed=0;
/*
* Specify number of observations for the data matrix
*/
n=30;
/*
* Define Correlation Matrix
*/
R={1 0.5, 0.5 1};
/*
* Define Vector of Standard Deviations
*/
Ds=Diag({2 6});
/*
* Compute Covariance Matrix
*/
S=Ds*R*Ds;
/*
* Compute Choleski Root for transformation
*/
T=Root(S);
/*
* Initialize data vector with random number seed
*/
X=J(n,NRow(S),Seed);
/*
* Generate Independent Standard Normals for the data matrix
*/
X=Rannor(X);
/*
* Now transform to have the desired covariance structure
*/
Y=X*T;
/*
* Save the data matrix
*/
Create NormalData From Y;
Append From Y;
Close NormalData;
/*
* Done.
*/
Quit;
Proc Corr Data=NormalData;
Run;
ODS HTML Close;
| Simulated Multivariate Normal Data |
| The CORR Procedure |
| 2 Variables: | COL1 COL2 |
| Simple Statistics | ||||||
| Variable | N | Mean | Std Dev | Sum | Minimum | Maximum |
| COL1 | 30 | 0.14495 | 1.88635 | 4.34847 | -3.80158 | 4.07903 |
| COL2 | 30 | -1.47885 | 7.01200 | -44.36546 | -22.98692 | 12.54134 |
| Pearson Correlation Coefficients, N = 30 Prob > |r| under H0: Rho=0 |
||
| COL1 | COL2 | |
| COL1 | 1.00000 |
0.57586 0.0009 |
| COL2 | 0.57586 0.0009 |
1.00000 |