# With an R function that expects a covariance matrix, can I give it a correlation matrix?

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.

• – Tim
Commented Oct 26, 2016 at 7:19

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.

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.

• Except when all variances are, indeed, equal to 1. Commented Oct 26, 2016 at 11:11
• You are right of course, I have updated the answer to reflect this. Commented Oct 26, 2016 at 11:17
• 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 Commented Nov 1, 2016 at 18:57