Vector notation for the slope of a line using simple regression

1.6k Views Asked by At

How can the equation for the slope of a line (using simple regression) be represented using vector notation (i.e. vectorized)?

$$\text{slope} = \frac{ \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y}) }{ \sum_{i=1}^n (x_i - \bar{x})^2} $$

I came across this representation in an answer on Stack Overflow:

$$\text{slope} = \frac{\left\langle {x \circ y} \right\rangle - \left\langle {x} \right\rangle \left\langle {y} \right\rangle}{\left\langle {x^2} \right\rangle - \left\langle {x} \right\rangle^2}$$

Where $\circ$ is element-wise multiplication (Hadamard product) and $\left\langle {} \right\rangle$ denotes the mean.

I can't figure out how to derive the vector representation from the original definition based on summations.

I'm curious if there is a more elegant (and intuitive) representation.