I am interested in generating data from a multivariate normal distribution, in which I have some control over the relation between variables. I have tried the following:
nvars = 11;
nobs = 70;
k = 15;
W = RandomVariate[NormalDistribution[], {nvars, k}];
MD = DiagonalMatrix@RandomVariate[NormalDistribution[], nvars];
K = W.Transpose@W + MD;
datasim = RandomVariate[MultinormalDistribution@K, nobs]
However, I am not satisfied with my approach, because if I set a higher number for nvars
and nobs
, it usually fails because the covariance matrix R
generated is not always positive semi-definite.
Does anyone know a better aproach to generate large covariance matrices in which I have some control over the relation between variables?
Thanks in advance for any help!