Random sparse positive semi-definite matrix

covariancenumerical methodspositive-semidefinitesparse matricesstatistics

I would like to generate random covariance matrices with the constraint that only particular pairs of variables are correlated.

A covariance matrix is a positive semi-definite matrix.
Given a set of indices $I=${$(i_1,j_1),(i_2,j_2),(i_3,j_3)…$} that represent the position of the non-zero elements, how can I generate a sparse random positive semi-definite matrix $A$ that a satisfy the condition $A_{ij}=0$ if $(i,j)\notin I$ ?

The simplest method to generate a random positive semi-definite matrix is to generate a random $M$ and compute $MM^T$, but I'm not sure if it's possible to adapt this method to the sparse case.

Best Answer

Let $A = [a_{ij}]$ have dimension $n$. Let $\delta_{ij}$ be independent random variables all with a uniform distribution on $(-1,1)$, i.e., $\delta_{ij} \sim U(-1,1)$. Set $a_{ii} = 2n+n \delta_{ii}$ for all $i$ and $a_{ij} = \delta_{ij}$ if $(i,j)$ is in your set and $i < j$. Set $a_{ij} = a_{ji}$ for $i > j$. Then $A$ is symmetric and strictly diagonally dominant by rows. It follows by Gershgorin's circle theorem that $A$ is symmetric positive definite.