On Tue, 24 Jun 2003, Horace Tso wrote:
> Suppose i have a random vector A of size n. I want to generate a vector
> B such that correlation between A and B is (exactly) a constant, ie.
> corr( A, B ) = d, where d is given number.
>
> This is not a statistic question. I'm not trying to find the joint
> distribution where rho equals d so that i can generate random samples
> out of it. And surely that can be done with rmvnorm(mu, rho). Rather, it
> is a simulation question. I want to find the set F such that for every U
> in F,
>
> corr(U, A) = d
Suppose A has variance s^2, and U is a vector of mean zero and variance
a^2 uncorrelated with B. Then corr(A+U, A) = s^2/(s^2+a^2). For d > 0
solve for a^2, and for d < 0 use -(A+U).
To find a suitable U, generate n N(0,1) vars, regress them on B and take
the residuals, then rescale to the required variance.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|