# Is the significance of difference in slopes equivalent to the significance of the slope of the difference of two series?

Say you have an independent variable, $x$, and two dependent variables $y_1$ and $y_2$. I want to calculate whether these two variables have a significantly different slope. I can do it by calculating separate regressions, and then using he method mentioned at Test a significant difference between two slope values.

I was wondering, would be equivalent to testing for the significance of the slope of the series $(y_1-y_2)$ [e.g. null hypothesis slope=0]? I tried it with a couple of hundred independent series, and the results look very similar (similar distribution of p-values), but I'd think if it were that easy, more people would use it, as the computation is simpler. So, why is it not the same?

If the x's are the same for both, you're effectively making the values paired (on $x$).

More generally - as in the case where you have two separate fitted lines - you don't have that.

When you do have the two sets of $y$ paired on $x$, then you could test for a difference in slope by taking differences $y_{2i}-y_{1i}$ and regressing that on $x$.

If the y-values for a given $x$ are independent (conditional independence), it should make no difference which you do.

$\hat{\beta_2}-\hat{\beta_1}=(X'X)^{-1}X'y_2-(X'X)^{-1}X'y_1=(X'X)^{-1}X'(y_2-y_1)$

showing the estimates are the same, and (assuming conditional independence):

$\text{Var}((X'X)^{-1}X'(y_2-y_1))=(X'X)^{-1}X'\text{Var}(y_2-y_1)X'(X'X)^{-1}$

$=(X'X)^{-1}X'((\sigma_1^2+\sigma_2^2)I)X'(X'X)^{-1}$

$=(\sigma_1^2+\sigma_2^2)(X'X)^{-1}X'X'(X'X)^{-1}$

$=(\sigma_1^2+\sigma_2^2)(X'X)^{-1}$

$=\text{Var}(\hat{\beta_2})+\text{Var}(\hat{\beta_1})$

(though the sample values won't be perfectly uncorrelated). So I think the two are at least asymptotically equal, and should be equally efficient at smaller samples. I don't think it matters which you use.

However, if the y-values are positively correlated, it would be important to work with the differences.

• Cool, thanks, I had a vague idea that it might require error independence, but I wasn't sure. – naught101 Feb 28 '15 at 6:19
• It was a fun question actually, I'd never been through that particular calculation before. (I already had come to the answer from general reasoning, but it's always best to follow through a couple of lines of algebra to make sure.) – Glen_b -Reinstate Monica Feb 28 '15 at 6:55