Linear regression where the x variable is an index Say I have two series of values, $x$ and $y$, and I want to calculate their linear regression. If I know that $x$ is just a running index (i.e. $x_i=i$), how can I use this to simplify the normal equations for linear regression?
Specifically, since the slope is just $c_{xy} \cdot {\sigma_y \over \sigma_x} $, if I'd have a simple expression for the correlation $c_{xy}$ (where $x$ is a running index) it'll be enough.
 A: Here's what I got by myself:
The definition $c_{xy}⋅{σ_x \over σ_y}$ is already equal to $cov(x,y)\over σ^2_x$, so all we need is a simpler expression for $cov(x,y)$ when $x$ is an index. 
Now, $cov(x,y)=∑^N_{i=0}(x_i−\bar x)(y_i−\bar y)$, where $x=i$ in my question.
For simplicity's sake, let's assume that there's an odd number of points (so $N$ is even), so we can reindex them from $−N/2$ to $N/2$ instead of $0$ to $N$.  Let $n=N/2$, we have: $cov(x,y)=∑^n_{i=−n}i(y_i−\bar y) = ∑^n_{i=−n}iy_i$ (the second term in the sum vanishes), which can be further reduced to $cov(x,y) = ∑^n_{i=1}2i \cdot (y_i-y_{-i})$.
Knowing the the variance $\sigma^2$ is equal to ${N^2-1}\over 12$, the result is just $ {12 \over {N^2-1}} \sum^{N/2}_{i=1} 2i \cdot (y_{N/2+i}-y_{N/2-i}) $ (in the original indices).
A: I tried to figure out how you derived the last part with that $2i$ and I failed.
It seems also you are not considering $N$ or maybe $N-1$ for the covariance.
During my PhD I had faced the same problem and what I had ended up with was:
$\frac{12}{N(N^{2}-1)} \sum_{i=1}^{(N-1)/2} i(y_{i_{0}+i}-y_{i_{0}-i})$
with $ i_{0} $ being the median value's index in the original set.
Those who have problems with your approach can give this a try.
