Constructing a positive definite covariance matrix

I am trying to construct a covariance matrix between a set of demands $t \in T$. The only information I have of the demands are the mean and the standard deviation. I intend to apply Cholesky Decomposition to this covariance matrix and the resulting values shall then be used in an optimisation problem related to Gamma-robustness (Bertsimas, Sim) to be protected against a set of worst-case correlations on each demand.

I started with constructing a covariance matrix as follows:

$$cov(t,t^\prime) = SD(t) SD(t^\prime) \rho$$

where $\rho$ is the correlation coefficient. I set $\rho$ to different values to observe the impact of correlation between different demands on the optimisation problem. The problem I currently have is that when I generate such a covariance matrix the Cholesky decomposition always returns an error saying the matrix isn't positive definite. I thus want to ask you for some suggestions to construct such an artificial covariance matrix where the only information at hand is the SD values.

Thank you.

• Your correlation matrix probably isn't positive definite. Eg. something like $\begin{bmatrix} 1 & -1 & -1 \\ -1 & 1 & -1 \\ -1 & -1 & 1\end{bmatrix}$ can't be a correlation matrix. – Matthew Gunn Oct 13 '16 at 7:20
• Yes, this is the error I keep getting. So, how can I construct one with the limited information available at hand? Additionally, I observed that by setting the value of $\rho$ to anything other than $\rho\in [0,1)$ leads to the error – crypto Oct 13 '16 at 7:52
• How many variables do you have? just 2? A ton? stats.stackexchange.com/questions/2746/… may be of interest – Matthew Gunn Oct 13 '16 at 7:54
• I may have a maximum of 100 variables. I dont want to generate random correlation matrices but the correlation between the variables shall be set using the parameter $\rho$ – crypto Oct 13 '16 at 8:27
• I have frequently needed to generate random covariance matrices. See, for example, the code at stats.stackexchange.com/a/230714/919 or stats.stackexchange.com/a/61068/919. – whuber Oct 13 '16 at 16:56