# How to prove the correlation between two variables using covariance

If two variables are related in this way,

$y=a+bx$

How to prove that these variables are perfectly correlated(correlation coefficient of 1) using covariance?

Need some guidance to start..

• They are perfectly correlated by the invariance property of correlation (second paragraph here). The answer by @IMA provides the computational details. Aug 7, 2013 at 8:18
• (1) Presumably the "variables" are $y$ and $x$; $a$ and $b$ are intended to be constants. (Otherwise, the conclusion may be incorrect.) (2) Proofs are sequences of statements proceeding by deductive rules from assumptions to conclusions. You tell us the desired conclusion, but what assumptions are available to you? In particular, what is your definition of correlation? One of the best is that it's the expectation of the product of the standardized variables. Starting from this, the proof becomes obvious because the linear transformation $x\to ax+b$ does not change the standardized value.
– whuber
Aug 7, 2013 at 13:20
• I had also better remark that any demonstration of this result--including the three proposed so far (in a comment and in two answers) is necessarily invalid! As a counterexample, consider the case $a=0, b=-1$: $x$ and $y$ are perfectly anticorrelated with coefficient $-1$, not $1$.
– whuber
Aug 7, 2013 at 13:26

The one above is right but it seems kind of strange to prove it via a linear model including assumptions. I think it is a bit easier still: $$Cov(x,y) = Cov(x,a+bx) = bCov(x,x) = b Var(x)$$ Which gives us for the correlation with $$y=a+bx$$ so $$V(y) = V(a+bx)$$: $$cor(x,y) = \frac{bV(x)}{\sqrt{V(x)}\sqrt{V(a+bx)}}\\$$ And because the properties of variance, $$a$$ is out and $$b$$ is squared:$$= \frac{bV(x)}{\sqrt{V(x)}\sqrt{b^2V(x)}} \\$$ Now it's just fractions$$= \frac{bV(x)}{\sqrt{V(x)}\sqrt{V(x)}\sqrt{b^2}} \\ = \frac{bV(x)}{\sqrt{V(x)}\sqrt{V(x)}|b|} \\ = \frac{bV(x)}{|b|V(x)} \\ =\pm 1$$

Important here is just to use the rules of variances. No need to assume a model or error term. Another way to think of this is that the correlation shows the linear relationship. If these variables are related like in the formula, they are obviously perfectly linear dependent and correlation must be 1

• The question is tagged as self-study, so the answer is probably too detailed in the first instance. Aug 7, 2013 at 8:29
• @Quantlbex It's so detailed, in fact, that it's wrong. (The error occurs in replacing $\sqrt{b^2}$ with $b$.)
– whuber
Aug 7, 2013 at 13:27

Start with an econometric model (including error term $e$)

$y=a+bx+e$

$cov(y,x)=cov(a+bx+e,x)=cov(a,x)+cov(bx,x)+cov(e,x)=0+bvar(x)+0$

So, $cov(y,x)=bvar(x)$

or, $b=cov(y,x)/var(x)$

but, we know that $cov(y,x)=cor(x,y)*sd(y)*sd(x)$

so, $b=cor(x,y)*sd(y)/sd(x)$

If $cor(x,y)=1$ (perfect positive correlation):

$b=sd(y)/sd(x)$

If $cor(x,y)=-1$ (perfect negative correlation):

$b=-sd(y)/sd(x)$

Note: by exogenity assumption, $cov(e,x)=0$, $sd()$ means standard deviation, $var()$ means variance, $cov()$ means covariance, and $cor()$ means correlation.

• what is the significance of b=sd(y)/sd(x)? Aug 7, 2013 at 4:02
• under that condition you will have two variables perfectly correlated. That is what you asked for, I think. Aug 7, 2013 at 4:06
• am i right to say that since sd(y)/sd(x) will be greater than zero, b will also be greater than zero. Aug 7, 2013 at 4:36
• The question is tagged as self-study, so the answer is probably too detailed in the first instance. Aug 7, 2013 at 8:29
• This entire exposition is mystifying. I believe the question concerns the correlation of $x$ and $a + bx$. In particular it does not ask to solve for $b$.
– whuber
Aug 7, 2013 at 13:29