1
$\begingroup$

I want to generate a matrix of values such that the correlations (e.g., Pearsons correlations) are close to a pre-defined set of values (e.g., corrs = [0.5, 0.7, -0.3, 0.9, 0.2]). For simplicity, we can assume we're only concerned with the correlation of pairs of columns.

For example, I may want a matrix with 4 columns and 100 rows, and the correlations between columns should be close to the following:

CORR(c1, c2) = corrs[0]
CORR(c1, c3) = corrs[1]
CORR(c1, c4) = corrs[2]
CORR(c2, c3) = corrs[3]
CORR(c2, c4) = corrs[4]
CORR(c3, c4) = corrs[5]

Depending on the parameters specified (matrix size, correlations), a solution may not exist, but for reasonable parameters, it seems like some algorithm should be able to come up with a solution.

Is there any areas of research that can help me accomplish this? It seems like something related to graphs and/or some iterative algorithm might be what I need, but I'm struggling with how to represent the problem mathematically or in a graph, and my knowledge of these areas is pretty limited.

$\endgroup$
3
  • 1
    $\begingroup$ It seems like a multivariate normal distribution (or multivariate Student's $t$ distribution, if you like) checks these boxes. Are there any additional requirements? $\endgroup$ – Sycorax Jul 19 '17 at 15:48
  • $\begingroup$ Thanks @Sycorax, that makes sense. I just adjust my covariance matrix accordingly. I'll try playing with this $\endgroup$ – Dolan Antenucci Jul 19 '17 at 15:52
  • 1
    $\begingroup$ This might be what you're looking for econometricsbysimulation.com/2014/02/… $\endgroup$ – user5292 Jul 19 '17 at 18:55
1
$\begingroup$

Following @Sycorax's recommendation, I used a multivariate normal distribution to generate my desired dataset.

I set the means and variances for my columns to 0 and 1 respectively, thus the covariance matrix is populated with just the desired Pearson correlations (since cov(X,Y) = corr(X, Y) * std_dev_X * std_dev_Y).

Caveat to myself and others: Apparently the covariance matrix should be positive-semidefinite for proper sampling to occur, so the input set of correlations will need to be arranged or modified to create a positive-semidefinite covariance matrix.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.