The user wants to impose a unique, non-trivial, upper/lower bound on the correlation between every pair of variable in a var/covar matrix.
For example: I want a variance matrix in which all variables have 0.9 > |rho(x_i,x_j)| > 0.6, rho(x_i,x_j) being the correlation between variables x_i and x_j.
Thanks.
Ok, something of a quick&dirty solution has been found, still if anyone know of a more exact way to get there, it'll be welcome.
I lost my original login, so i'm reposting the question under a new login. The previous iteration got the following answer
*you mean pseudo-random, that's the correct terminology for semi random – Robert Gould
*Good point, but I think he meant semi pseudo-random (the pseudo is assumed when talking about computer randomness :-p) – fortran
*With "correlation", do you mean "covariance"? – Svante
*no, i really do mean correlation. I want to generate a positive definite matrix such that all the correlations have tighter than trivial bounds. – vak
*See my answer. Do you insist that the sample correlations lie within the specified bounds, or just the population correlations that generate the sample? I do suggest an idea that may work if your problem is the former. – woodchips
*woodship: no i'm afraid your solution will not work, please see my answer in the original threat (link above). Thanks.
You can create a set of N random vectors of size M and unit variance. And add to them a random vector (size N and unit variance) multiplied by a certain number k. Then you take the correlation between all those vectors, that will be a positive definite matrix. If M is very big then there will be no variance in the correlation distribution and the correlation will be: k^2/(1+k^2). The smaller M gets the wider the distribution of the off diagonal elements. Alternatively, you can let M be very large and multiply the "common vector" by a different k each. You might get tighter control if you play with these parameters properly. Here goes some Matlab code to do that:
OK, fantastic Gregg: we're getting somewhere. Combining your idea with that of woodchips, yields this alternative approach. It's mathematically very dirty but it seems to work:
Basically, this is the idea (say upper bound =.8 and lower it bound=.6), it has a good enough acceptance rate, which is not 100%, but it'll do at this stage of the project.
Here is your response to my answer in the original thread:
"Come on people, there must be something simpler"
I'm sorry, but there is not. Wanting to win the lottery is not enough. Demanding that the Cubs win the series is not enough. Nor can you just demand a solution to a mathematical problem and suddenly find it is easy.
The problem of generating pseudo-random deviates with sample parameters in a specified range is non-trivial, at least if the deviates are to be truly pseudo-random in any sense. Depending on the range, one may be lucky. I suggested a rejection scheme, but also stated it was not likely to be a good solution. If there are many dimensions and tight ranges on the correlations, then the probability of success is poor. Also important is the sample size, as that will drive the sample variance of the resulting correlations.
If you truly want a solution, you need to sit down and specify your goal, clearly and exactly. Do you want a random sample with a nominal specified correlation structure, but strict bounds on the correlations? Will any sample correlation matrix that satisfies the bound on the aims be satisfactory? Are the variances also given?
Perhaps this answer will help operationalize it:
One class of matrixes that has this property of non-negative definiteness is the Wishart Distribution. And samples from ~W() such that all non-diagonal entries are between some bounds [l,u] would fit your question. However, I don't believe this is the same as the distribution of all positive-definite matrices with non-diagonals in [l,u].
On the wikipedia page there is an algorithm for calculating from ~W().
A simpler, hackish solution (possibly approximating this) is to:
(given that u>l and l>0)
So this seems non-trivial to truly answer!
As other posters have suggested, you can generate from Wishart, then keep the ones where the property you want is true, but you might be sampling for a long time! If you exclude those who are 0-definite (is that a word?) then this should work fine for generating good matrices. However this is not the true distribution of all pos-def matrices whose off-diags are in [l,u].
Code (in R) for dumb-sampling scheme proposed above