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.

  • 2
    $\begingroup$ In what way was mvtnorm unsuccessful?! $\endgroup$ – P.Windridge Nov 8 '15 at 9:27
  • $\begingroup$ Is your problem that the sample correlation isn't identical to your specified (population) correlation? $\endgroup$ – Glen_b Nov 8 '15 at 16:18
  • $\begingroup$ @Glen_b yes, somehow. $\endgroup$ – SlightlyBuilt Nov 11 '15 at 19:43
  • $\begingroup$ 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. $\endgroup$ – 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.

| cite | improve this answer | |
  • $\begingroup$ 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)? $\endgroup$ – whuber Nov 8 '15 at 14:48
  • $\begingroup$ 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 $\endgroup$ – P.Windridge Nov 8 '15 at 15:25
  • $\begingroup$ Why not suggest PCA? $\endgroup$ – whuber Nov 8 '15 at 16:13
  • $\begingroup$ @P.Windridge nice. would you please represent it with an example in R? $\endgroup$ – 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.

| cite | improve this answer | |
  • $\begingroup$ thanks for the tip. by the way I was taking n=50 for each variable. $\endgroup$ – SlightlyBuilt Nov 11 '15 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.