lundi 2 mars 2015

How to make a vector of random numbers with a specified covariance to another vector

I'd like to know how to make a vector (let's call it x2) of random numbers of length n, whose expected covariance to a known vector x1 (which is known; not randomly generated) has been specified.


So, if x1 is a list of 1000 numbers, how do I generate a vector x2 of length 1000, where the sample covariance of x1 and x2 will be, for example, 0.6 on average? Basically I want to create a "partner" for every number in x1, where the average product of their deviations tends to be such that cov(x1,x2) is 0.6 (or thereabouts; it will only be exactly 0.6 if x1 and x2 are very long vectors, due to stochasticity from rolling the random numbers).


More of a stats question than an R question really! Thanks, all the best.





Aucun commentaire:

Enregistrer un commentaire