s-news
[Top] [All Lists]

Re: Recreating correlation

To: Horace Tso <Horace_Tso@pgn.com>
Subject: Re: Recreating correlation
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Tue, 24 Jun 2003 21:55:05 +0100 (BST)
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <sef855ee.017@pgn.com>
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


<Prev in Thread] Current Thread [Next in Thread>