How can I generate a covariance matrix with specified correlation coefficient?

262 Views Asked by At

I know it is easy to get a 2$\times$2 covariance matrix by specifying correlation coefficient $\rho\in[-1,1]$, as $\sigma_{12}=\rho\sigma_1\sigma_2$. Since $\sigma_1$ and $\sigma_2$ are scalar, I can easily get the cross-correlation.

However, what if the covariance is $4\times4$? What I mean is, I have two covariance matrices of $2\times2$. I want to generate the cross-correlation between them for all degree of correlation.

If I simply vary the 4 correlation coefficients (the relations between 2 varibles is 4), does this make a valid covariance? I would expect that cov(x1,x3) and cov(x2,x4) are related because of cov(x1,x2).

Demonstration in Matlab will do.