Regression by the model $y_t = β + u_t$ I have 30 data points and should calculate the residuals $u_t$ from them.
My regression model is:
$$y_t = β + u_t$$
Data Points
-15,6
-21,6
-19,5
-19,1
-20,9
-20,7
-19,3
-18,3
-15,1
-14,1
-14,9
-26,4
-26,87
-23,11
-25,38
-20,60
-14,96
-10,54
-4,72
-0,36
-4,17
4,14
1,09
6,81
17,27
19,24
24,35
25,35
30,02

I calculated by the ordinary least square method that β is
$β=-y_t$
so from all the data points $β=26,8722467$
and then  $u_t = y_t-β$
Is this correct?
 A: Best way to calculate your result is to plug in your values in the formulas proposed above. However, if you are interested in the derivation of the estimator in order to get some more insides it probably best to check out how the estimator is derived exactly. A nice summary of how the estimator for OLS is derived can be found here 
http://economictheoryblog.com/2015/02/19/ols_estimator/
However, the derivation of the estimator is in matrix notation and might take some time to get used to.
A: The algebra isn't correct, no, in a bunch of different ways.
I assume (though it isn't stated) that the $u_t$ are independent and identically distributed errors.
Firstly, $\beta$ is a single unknown population parameter, so it can't be true that $\beta = -y_t$.
You might have an estimate of $\beta$ that is a function of all the available $y_t$ values.
You need to distinguish the population parameter from its estimate. The usual approach is to use a symbol like $\hat{\beta}$ to represent an estimate, especially when dealing with least squares or ML.
OLS minimizes $\sum_t (y_t - \hat{y_t})^2$, where in this case, $\hat{y_t}=\hat{\beta}$ for all $t$.
That is the exercise is to find $\hat{\beta}$ so as to minimize $S = \sum_{t=1}^n (y_t - \hat{\beta})^2$.
In this case, you should be able to derive that $\hat{\beta} = \bar{y}$.
That estimate is not positive.
Once you have $\hat{\beta}$, then you have $\hat{u}_t = y_t - \hat{\beta}$
A second issue here is that with this data that simple model is untenable.
--
As to how to get $\hat{\beta} = \bar{y}$; I will outline it for you.
To minimize $S$, set $\frac{\partial S}{\partial \hat{\beta}} = 0$ (you should still show it's a minimum, though; this is probably most easily done in this particular case by looking at the sign of the second derivative).
A: Adding a little to  @Glen_b 's answer: 
The goal of OLS regression is inherent in its name: Ordinary least squares. That is, we want to minimize the squared errors. When (as in your example) there are no independent variables, then the model would (at least in my lexicon) be a little mislabeled as "regression". Usually in regression analysis we do have an IV and we want to compare the model with the IV to this simple one.
As for how it's derived that, when there is no IV the best estimate is the mean, see. e.g. Wikipedia
$\hat\beta = \frac{ \sum{x_iy_i} - \frac{1}{n}\sum{x_i}\sum{y_i} } { \sum{x_i^2} - \frac{1}{n}(\sum{x_i})^2 } = \frac{ \mathrm{Cov}[x,y] }{ \mathrm{Var}[x] } , \quad \hat\alpha = \overline{y} - \hat\beta\,\overline{x}\ . $
but here you have no X, so $\hat{\beta}$ is really 0 and you just get $\hat{\alpha} = \overline{y}$. But another name for $\alpha$ is $\beta_0$.
