# Random generation of n-dimensional data with possibly correlated variables

I would like to generate a set of artificial data using another input set from which correlations between variables can be extracted. Not all variables are binary, but the data can easily be extended to be so, at the cost of increased dimensionality.

I was only able to find a method for the generation of correlated artificial binary data on a working paper by Friedrich Leisch, Andreas Weingessel and Kurt Hornik.

Are there other recommended methods, especially ones that don't require the data to be binary?

-
Are you asking how to generate non-independent correlated binary data? Or, are you asking how to simulate data from an arbitrary multivariate distribution that is possibly a mix of discrete and continuous data, with pre-specified correlation? I don't think the latter is, in general, possible – Macro Jun 15 '12 at 12:51
A distribution on $n$ binary variates is equivalent to a distribution on their $2^n$ possible joint values, so why not just simulate from that (discrete) distribution? It's fast and easy to do so. (One simple algorithm requires only about $H$ uniform variates where $H$ is the entropy of the distribution in bits; faster algorithms exist.) The existence of that working paper suggests I'm overlooking an important issue here... This approach to binary simulation generalizes easily to any discrete multivariate distribution. – whuber Jun 15 '12 at 13:06
@whuber, re: "A distribution on n binary variates is equivalent to a distribution on their $2^n$ possible joint values, so why not just simulate from that (discrete) distribution?" you make that sound so simple. If you knew the joint probabilities then, yes, that is trivial. But, the OP appears to describe a situation where you know the marginal probabilities and the correlations. In general, for binary data, that's not enough information (as discussed in a thread that we both participated in a couple weeks ago). – Macro Jun 15 '12 at 13:21
Thanks, @Macro: that may be the point I am missing. But what do you make of the beginning of this question, which indicates there is an "input set" of data? In other words, the correlations are not the only information available and indeed, it appears an estimate of the full distribution might readily be obtained. I am wondering whether using only the correlations for simulation is an unnecessary restriction imposed by the OP. – whuber Jun 15 '12 at 13:25
The non-binary data is discrete. It is being converted to binary classes using dummy coding. – Joao Azevedo Jun 15 '12 at 15:29

One approach to generating multivariate random data with correlations is to use a copula. Basically you generate n-dimensional data with uniform margins and a correlation structure, then transform the data to the marginal distribution of interest (binary variables can be generated by simply seeing if the value is greater than a cut-off). This does not guarentee an exact correlation with the transformed variables, but does give a general correlation structure and can be used with any distribution with an inverse CDF.

This could be used to generate a dataset with a mixture of binary variables and continuous variables from other distributions (or other discrete variables as well). You can simulate several datasets and check the level of correlation and if it is not close to what you were hoping for, go back and adjust the copula accordingly and try again.

-

Look here: Ruscio, J., & Kaczetow, W. (2008). Simulating multivariate nonnormal data using an iterative technique. Multivariate Behavioral Research, 43, 355-381.

-

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

This reply is identical to stats.stackexchange.com/questions/44586. Can you provide more details so that your answers remain self-contained and indicate how they apply in the present context? – chl Nov 28 '12 at 11:45