# Correlation between Weighted Sum of Random Variables and Individual Random Variables

Given the following set of random variables and constants,

\newcommand{\inreala}[2]{\in \mathbb{R}^{#1 \times #2}} \newcommand{\var}{\mathrm{Var}} \newcommand{\cov}{\mathrm{Cov}} \newcommand{\corr}{\mathrm{Corr}} \begin{align*} \text{Constants} :\forall i : \alpha_i \in \mathbb{R}^1 \\ \forall i \neq j: \cov(X_i, X_j) & :=\gamma_{i,j} \neq 0 \\ \forall i : \var(X_i) &= 1 \\ D &\in \mathbb{N}\\ \text{Random variables} : \left\{ X_i \right\}_{i=1}^D, Z & \in \mathbb{R}^1\\ Z &:= \sum_{i=1}^D \alpha_i X_i\\ \end{align*}

how can we choose $\alpha_i$ such that the correlation between $X_i$ and the $\alpha$-weighted sum $Z$ is a desired value?

More precisely, for fixed $\left\{\alpha_j\right\}_{j \neq i}$, desired correlation $c_i$: find $\alpha_i$ s.t. $\corr(X_i, Z) = c_i$.

If I understand correctly so far, this will be a function of $\left\{\gamma_{i,j} \right\}_{i \neq j}$ and $\left\{\alpha_j\right\}_{j \neq i}$.

• What is meant by $\alpha_i \in \mathbb R^{1\times 1}$? Is $\alpha_i$ an ordered pair of real numbers $\alpha_i = (\alpha_{i,1}, \alpha_{i,2})$? Or did your excessive formalism lead you astray and the $\alpha_i$'s are ordinary real numbers because that $^{1\times 1}$ is meant literally to be $^1$ on the grounds that $1\times 1 = 1$? Jan 26, 2018 at 2:55
• Have you computed $\operatorname{Cov}(X_i, Z)$ in terms of the $\alpha_i$? If not, then start there. The rest is (simple) linear algebra.
– whuber
Jan 26, 2018 at 14:23
• @DilipSarwate $\alpha_i$ are just ordinary real numbers. I simplified the notation above. Jan 26, 2018 at 17:45
• @whuber thanks for the tip. I've computed it for the $D=2$ case: $\operatorname{Corr}(X_1, Z) = \frac{\alpha_1 + \alpha_2 \gamma_{1,2}}{\sqrt{\alpha_1^2 + \alpha_2^2 + 2 \alpha_1 \alpha_2 \gamma_{1,2}}}$. Having issues generalizing beyond that. My linear algebra is rusty -- any further pointers appreciated :) Jan 26, 2018 at 17:54
• This is only a two-variable problem! When you fix all the other $\alpha_j$ you are specifying a variable $Y=\sum_{j\ne i} \alpha_j X_j.$ You can find its variance and covariance with $X_i$ easily. Your problem therefore consists of finding a single $\alpha_i$ for which the correlation of $X_i$ with $\alpha_i X_i + Y$ equals $c_i$.
– whuber
Jan 26, 2018 at 18:52

Let $Y := \sum_{j \neq i} \alpha_j X_j$; then:
\newcommand{\var}{\operatorname{Var}} \newcommand{\cov}{\operatorname{Cov}} \newcommand{\corr}{\operatorname{Corr}} \newcommand\covxiy{\cov(X_i, Y)} % gamma \newcommand\corrxiz{\corr(X_i, Z)} %c \begin{align*} c_i \equiv \corr(X_i, Z) &\equiv \corr(X_i, Y+ \alpha_i X_i)\\ &= \frac{\cov( X_i, Y + \alpha_i X_i)}{\sqrt{\var(X_i) \var(Y + \alpha_i X_i)}}\\ &= \frac{\covxiy + \alpha_i }{\sqrt{1 + \alpha_i^2 + 2 \alpha_i \covxiy}}\\ \end{align*}\\
Now, solving for $\alpha_i$:
\begin{align*} \Rightarrow \alpha_i = \frac{ \covxiy(1 - c_i^2) - c_i\sqrt{ \covxiy^2 c_i^2 - c_i^2 - \covxiy^2 + 1 }}{c_i^2 -1 }\\ \end{align*}
Of course, what I really wanted was a full vector of $\vec{\alpha}$ corresponding to a desired vector of $\vec{c}$, but my question didn't ask that. I suppose there's some system of above such equations that would lead to such a solution.