5
$\begingroup$

The R function mvrnorm from the MASS package generates random numbers from a multivariate normal distribution. It expects a covariance matrix as an input, but I want to give it a correlation matrix. Is this statistically valid?

My understanding is that correlation is just a standardized form of covariance.

$\endgroup$
1

2 Answers 2

5
$\begingroup$

A correlation matrix is a covariance matrix (of standardized variables) so you can do it (a correlation matrix is a valid covariance matrix* after all) -- the question is whether you end up with what you need.

You'll get multivariate normals with unit variance, with the population correlation matrix you supplied as a covariance.

If you don't mind all your variances being 1, that should be fine.

* if you supply a sample correlation matrix, it is possible to get a matrix that's not positive definite -- it's even possible to get a matrix that's not positive semidefinite. This would be a problem for the function. For example if the correlations are calculated "pairwise" (ignoring missingness in other variables than the two you're computing the current correlation of) you can easily get this issue.

$\endgroup$
3
$\begingroup$

No you cannot do this, those two things are not the same thing. There is no way, in general, you can go from correlation to covariance without knowing the individual variances. As pointed out in the comment below, the correlation will equal the covariance if all the variances are indeed $=1$.

The formula for the correlation is

$$ Cor(x,y)=\frac{cov(x,y)}{\sigma_x \cdot \sigma_y} $$

So if you wish to specify the correlation, rather than the covariance, perhaps because it is easier to talk about correlation (since it is scale independent). You can create the correlations you wish, along with whatever variance you wish, from this you form a propper covariance matrix - and feed it to the function.

$\endgroup$
3
  • 1
    $\begingroup$ Except when all variances are, indeed, equal to 1. $\endgroup$
    – Firebug
    Commented Oct 26, 2016 at 11:11
  • $\begingroup$ You are right of course, I have updated the answer to reflect this. $\endgroup$
    – Repmat
    Commented Oct 26, 2016 at 11:17
  • $\begingroup$ This answer is technically correct, but for my purposes I don't need the variances. Next I use pnorm to convert from normal distributions to percentiles, then I use the percentiles to determine the place of a simulant in several distributions $\endgroup$
    – rsoren
    Commented Nov 1, 2016 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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