生成具有给定平均相关性的随机相关矩阵 [英] Generating random correlation matrix with given average correlation

查看:113
本文介绍了生成具有给定平均相关性的随机相关矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成一个随机相关性 R 中的矩阵,其中平均相关性(不包括对角线)为0.3.

I would like to generate a random correlation matrix in R of 1000*1000 where the average correlation (excluding diagonal) is 0.3.

我从clusterGeneration库中查看了genPositiveDefMat,但是我不知道如何指定给定的相关性.

I looked at genPositiveDefMat from library clusterGeneration but I couldn't figure out how to specify a given correlation.

推荐答案

这样一个无聊的矩阵示例是

A boring example of such a matrix would be

C = (1-m)*I + m*U*U'

其中I是单位矩阵,U是一个全1的向量,m = 0.3. C是正定的,平均(实际上是每个)非对角线元素是m.

where I is the identity matrix, U a vector of all ones and m = 0.3. C is positive definite and the average (indeed every) off-diagonal element is m.

所以我们可以尝试生成形式为

So we could try generating a matrix of the form

C = D + alpha*U*U'

其中D是对角线和正定数,α是正缩放器,U是随机"向量.这样的矩阵将是正定的.为了使非对角线元素具有正确的平均数,需要显示一点代数

where D is diagonal and positive definite, alpha a positive scaler and U a 'random' vector. Such a matrix will be positive definite. For this to have the correct average of the off diagonal elements a little algebra shows

alpha = dim*(dim-1)*m / (S*S-T)

其中

S = Sum{ i | U[i] }
T = Sum{ i | U[i]*U[i]}

只要U的所有元素都是正数,我们将拥有

As long as all the elements of U are positive, we will have

S*S>T

所以alpha将为正.

and so alpha will be positive.

要使C的对角元素为1.0,我们需要

For the diagonal elements of C to be 1.0, we require

D[i] = 1 - alpha*U[i]*U[i] (i=1..dim)

,并且所有这些都必须为非负数.

and all of these must be non negative.

las,我一直都无法从理论上找到应该如何选择U的元素来保证这一点.但是,从实验的角度来看,如果U的元素是1.0到5.0之间的统一随机数,则我看不到D [i]中的任何一个为负的情况.

Alas I have been unable to find theoretically how the elements of U should be chosen to guarantee this. However experimentally, if the elements of U are uniform random numbers between 1.0 and 5.0, I've not seen a case where any of the D[i] are negative.

U的元素上限(上面的5.0)控制各种相关程度的差异.在5.0时,它们在0.03到0.8之间变化;在2.0的上限时,它们在0.13和0.53之间变化. 选择上限太高会增加方法失败的可能性(D不为正).

The upper limit for the elements of U, 5.0 above, controls how different the various correlations are. With 5.0 they vary between around 0.03 and 0.8, whild with an upper limit of 2.0 they vary between around 0.13 and 0.53. Choosing the upper limit too high will increase the likelihood of the method failing (D not positive).

这篇关于生成具有给定平均相关性的随机相关矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆