mvnormal | Generate multivariate normal samples | mvnormal |
The MVNORMAL macro generates random samples from multivariate normal distributions with a specified covariance matrix and one or more specified mean vectors.
The macro uses the CALL VNORMAL routine in SAS/IML to generate the samples.
The MVNORMAL macro is defined with keyword parameters. The arguments may be listed within parentheses in any order, separated by commas. For example:
%mvnormal(data=mycorr, var=X1 X2 X3 X4);
TYPE=
parameter. This must be in a form
similar to that produced by PROC CORR with the OUTP=
option, and possibly the COV option as well. For a correlation
matrix, this will contain correlations
(_TYPE_='CORR'
) and standard deviations (_TYPE_='STD'
);
a covariance matrix will contain observations of _TYPE_='COV'.
X1-X5
.
TYPE=COV
]
vector(s)
for the
VAR=
variables. One group of N obsrvations is generated for
each observation in the MEANS=
dataset.
MEANS=
dataset should contain one observation for each group.
N=10
]
OUT=SAMPLE
]
%include macros(mvnormal); *-- or include in an autocall library; *-- common correlation matrix for all groups; data corr; _type_ = 'CORR'; input _type_ _name_ $ X1 X2 X3; cards; CORR X1 1 .5 .3 CORR X2 .5 1 .2 CORR X3 .3 .2 1 STD . 10 5 7 ; data means; input gp group $ _type_ $ X1 X2 X3; cards; 1 A MEAN 10 10 10 2 B MEAN 20 20 20 3 C MEAN 30 30 30 %mvnormal(data=corr, type=CORR, var=X1 X2 X3 ,means=means ,class=group );