# Create uncorrelated random multivariate normals

Creating correlated random variables is an easy task in R, especially the normal distribution. But what I need is to generate variables (for example 5 standard normals) with very low correlations (e.g., below 0.05). I tried mvtnorm package several times with no success.

I'm just curious, we use methods (like Cholesky decomposition) to transform uncorrelated variables into correlated. Can we do it the other way around?

Edit: I want a method that makes multiple "correlated" normal variables "extremely low correlated" without trial & error with a reasonable sample size (say 50) implemented in R.

• In what way was mvtnorm unsuccessful?! – P.Windridge Nov 8 '15 at 9:27
• Is your problem that the sample correlation isn't identical to your specified (population) correlation? – Glen_b Nov 8 '15 at 16:18
• @Glen_b yes, somehow. – SlightlyBuilt Nov 11 '15 at 19:43
• Since I assume you realize that the sample correlation simply won't equal the population correlation, I think you're going to have to clarify what you need. – Glen_b Nov 11 '15 at 22:15

Suppose $X$ is multivariate normal.

Then by definition we can write $X = \mu + CZ$ for a (deterministic) vector $\mu$, matrix $C$ and random vector $Z$ of independent standard normal (i.e. $N(0,1)$) variables.

(So $\Sigma = CC^T$ is the covariance matrix).

Thus if $C$ is invertible then $$C^{-1}(X-\mu) = Z$$ is a vector of independent (and hence uncorrelated) standard normals.

Note, if you are given pos. def. $\Sigma$ upfront, then to calculate $C = (\Sigma^{1/2})^{-1}$ you would probably want to first calculate the square root (e.g. using Cholesky) and then invert that.

• I can't tell which question you are answering: are you trying to explain how to create correlated variables (which is the objective of the links you provide) or uncorrelated variables (which appears to be what is asked on the last line)? – whuber Nov 8 '15 at 14:48
• Yes on rereading that is probably what the OP wants, and the answer I linked to is the wrong way round -- will edit it later. In the meantime, short answer: yes you can go from (non-singular) multivariate normal to uncorrelated normal but you need to calculate the inverse square root of the covariance matrix – P.Windridge Nov 8 '15 at 15:25
• Why not suggest PCA? – whuber Nov 8 '15 at 16:13
• @P.Windridge nice. would you please represent it with an example in R? – SlightlyBuilt Nov 11 '15 at 20:15

Independent random variables should by definition not be correlated, but if you are only generating a small number of points you'll get some correlation by chance. You should find as you generate a larger dataset that you get lower correlations.

If, for some reason, you need to generate a small dataset with extremely low correlations between your five variables, you might instead generate say 50 variables, calculate their correlation matrix and select 5 with the lowest correlation.

• thanks for the tip. by the way I was taking n=50 for each variable. – SlightlyBuilt Nov 11 '15 at 19:56