GenMVN: Generating multivariate normal random variables


Download from my github site here

for citation: Daryanto, Ahmad (2015). GenMVN: An SPSS Macro to Generate Multivariate Normal Random Variables. retrieved from https://sites.google.com/site/ahmaddaryanto/scripts/generating-multivariate-normal-random-variables.[Accessed: Date Month Year]

GenMVN is a SPSS macro in an spd format for generating multivariate random variables for a specified number of cases.

Once installed, the macro can be found in the SPSS under Analyze menu.

The input data needed are correlation matrix, mean values and standard deviations of each variable..

These three types of data are organized in rows in an active data view windows in SPSS.

Steps:

1. Generate k standard normal random variables (each having mean 0 and standard deviation 1), store in matrix Z

2. For a given covariance matrix S, use Cholesky decomposition to get matrix C, S=CC(T), C(T) means the transpose of C.

3. k multivariate normal random variables with mean zero is ZC

4. k multivariate normal random variables with vector of mean U is ZC+U

Notes:

In step 1, the macro generates uniformly distributed random variables U~(0,1), then use an inverse-transform method to generate standard normal variables.

Since there is no a closed form for the inverse of the cumulative distribution function of normal distribution, the macro uses the easiest Bowling's logistic approximation (see ref 2). However, the standard normal variables generated will not have zero correlations. To ensure zero correlations, the trick is to perform Principal Component Analysis on those variables and the principal component scores (the components are orthogonal, hence zero correlations) are retained as the new standard normal variables.

Matrix S should be positive definite matrix and symmetric. The macro checks if the eigen values of S greater than zero, otherwise the program stops.

References

  1. Thomopoulos, Nick T. 2013. Essentials Monte Carlo Simulation: Statistical Methods for Building Simulation Models. Springer.

  2. Bowling S.R., Khasawneh M.T., Kaewkuekool S. and Cho B.R., 2009. A logistic approximation to the cumulative normal distribution. Journal of IndustrialEngineering and Management, 2(1):114-127.

Example of data input: