# Algorithm to Construct Covariance matrices

I am involved in a project where i need to construct some examples using non-negative Multivariate Gaussian Random variables(log-normal random variables). Part of the computation requires calculating the covariance matrices. Since i do not have any data and i am plucking numbers out of the air i was hoping if some one would be kind to verify that the following algorithm is valid or not.

1. I assume a bunch of positive log values as standard deviations for my variables. Lets call these $$s =[\sigma_1,\cdots, \sigma_n]$$
2. I then compute $$s^2 = s^{T}s.$$
3. I assume a correlation matrix $\rho$, which are all non-negative and this matrix is symmetric.
4. Multiply $\rho$ with $s^2$ element wise. This is a non standard operation, what i am suggesting here is the $(i, j)$th element of $s^2$ is multiplied by $(i, j)$th element of $\rho$. The matrix produced when all the element-wise operations are complete is the covariance matrix $\Sigma$.

I have verified in mat lab that $\Sigma$ values of my examples are Choleski decomposable, as in i get a valid upper triangle matrix as result. Hence i am inferring from that they are positive-definite. These matrices are also symmetric.

Can we infer based on the process and Choleski factorization, that covariance matrices are valid ?

http://math.stackexchange.com/q/250912/23874

-

(i) Where you have $s^\top s$ did you mean $ss^\top$?
(ii) Where you say multiply element-wise, do you exclude the diagonal?

If the answer is 'yes' to both item (i), you should get a covariance matrix corresponding to pairwise correlations of ρ $\rho_{ij}$ for all pairs.

If you can compute a full Choleski it will be a valid covariance matrix - regardless.

Edit: it appears you meant $\rho_{ij}$ where you wrote $\rho$, so point (ii) is irrelevant. I have edited to reflect that.

-
Answer to first one is yes. I ovelooked the way i wrote that, as the matrices in question would not have matching dimensions for multiplication. For the second part i did not exclude the diagonal elements but the correlation values here would be 1 as for the diagonals we are just multiplying the standard deviations of the same rv with 1. also by full choleski, did you just mean computing the upper and lower triangle matrices which mutliply to give the original matrix or is there any other steps i am missing ? – Hardy Dec 4 '12 at 22:05
You should not use a single symbol, $\rho$ to represent different correlations. You need to use $\rho_{ij}$ or your explanation is actively misleading. No, you're not missing anything; you only need to be able to compute it right to the end without the diagonals getting 'small'. – Glen_b Dec 4 '12 at 22:44
I apologise from my confusing choice of representation. Thank you very much for your help. – Hardy Dec 4 '12 at 23:15