# Slope estimator for the regression line through the origin

For a regression line through the origin with the equation:

$$\tilde{y}=\tilde{\beta_1}x$$

How did we use OLS to get the below equation? I know it is by minimising the SSR but I can't seem to work it out by plugging in the values into the formula for SSR.

$$\sum (y_i -\tilde{\beta_1}x_i)^2$$

And furthermore, how do we use calculus to get the first order condition for equation directly above?

First order condition:

$$\sum x_i(y_i-\tilde{\beta_1}x_i) = 0$$

Is it a partial derivative? If so, where did the exponent (2) go?

This is just the derivative. For example, our loss function is the sum of squared residuals, or $$S(\beta) = \sum_{i=1}^n (y_i - \beta x_i)^2.$$ We want to minimize this, so we take the first derivative: $$\frac{dS}{d\beta} = -2 \sum_{i=1}^n (y_i - \beta x_i) x_i.$$
We set it equal to zero to find the minimum, so $$-2 \sum_{i=1}^n (y_i - \hat{\beta} x_i) x_i = 0 \\ \hat{\beta} =\frac{\sum_{i=1}^n y_i x_i}{\sum_{i=1}^n x_i^2}.$$
• Why is our loss function the sum of squared residuals? Is it because $\hat{u}=\tilde{y}-\tilde{beta_1}x$? – Munir Malik Nov 20 '19 at 19:47