OLS in terms of means and sample size Given a model:
$$
y = \beta_0 + \beta_1 \cdot f + u
$$
Where $f$ is dummy $=1$ if female and $0$ otherwise, y is height in cm. The sample size is $n_{female}=n_{male}=100 \rightarrow 200$ in total. Further $\bar{y}_{male} = 175$ and $\bar{y}_{female}=165$. Calculate the estimates of parameters.
My attempt:
Using the well know formula:
$$
\boldsymbol{\hat{\beta}} = (\boldsymbol{X}'\boldsymbol{X})^{-1} \boldsymbol{X}'\boldsymbol{y}
$$
I get:
$$
\begin{bmatrix}
200 & 100  \\
100 & 100  \\
\end{bmatrix}
^{-1}
\begin{bmatrix}
170 \cdot 200 \\ 
165 \cdot 200
\end{bmatrix}
$$
First the elements in $(\boldsymbol{X}'\boldsymbol{X})^{-1}$, since $X$ is just a bunch of one's, there are 100 female's in the sample and there are 200 males and females in total. For $\boldsymbol{X}'\boldsymbol{y}$, the first element is the "grand mean" of 170, and the second is the just the sample mean of height for females. Both are scaled by 200, since I did not "down-scale" $(\boldsymbol{X}'\boldsymbol{X})^{-1}$. 
Is the correct? I ask, because the solution (when multiplying) results in some (very) odd numbers.
 A: The approach is correct, but there's a slight numerical error: there are only $100$ females, not $200$.  The mean heights for males and females can be converted to sums via
$$\text{Sum of male heights} = 100 \times 175$$
and
$$\text{Sum of female heights} = 100 \times 165.$$
Therefore the sum of all heights is
$$\text{Sum of all heights} = 100 \times 175 + 100\times 165 = 200 \times 170,$$
as indicated in the question.  Consequently the Normal equations are
$$\pmatrix{200 & 100 \\ 100 & 100}\pmatrix{\hat\beta_0 \\ \hat\beta_1} = \pmatrix{200\cdot170 \\ 100 \cdot165}$$
(not $165\cdot 200$ on the right side), with solution
$$(\hat\beta_0, \hat\beta_1) = (175, -10).$$
A: Im quite confused. What does $u$ mean? Are these residuals? If so, then 
$\mathbf{X'X}$ = $\begin{bmatrix}
200 & 100 \\ 100 & 100
\end{bmatrix}$
since
$\mathbf{X} = \frac{\partial{y}}{\partial\beta} = 
\left[\begin{array}{cccc|cccc}
\frac{\partial{y_1}}{\partial\beta_1} & \frac{\partial{y_2}}{\partial\beta_1} & ... & \frac{\partial{y_{n_f}}}{\partial\beta_1} & \frac{\partial{y_{{n_f}+1}}}{\partial\beta_1} & \frac{\partial{y_{{n_f}+2}}}{\partial\beta_1} & ... & \frac{\partial{y_{n_{{n_f}+{n_m}}}}}{\partial\beta_1} \\
\frac{\partial{y_1}}{\partial\beta_2} & \frac{\partial{y_2}}{\partial\beta_2} & ... & \frac{\partial{y_{n_f}}}{\partial\beta_2} & \frac{\partial{y_{{n_f}+1}}}{\partial\beta_2} & \frac{\partial{y_{{n_f}+2}}}{\partial\beta_2} & ... & \frac{\partial{y_{n_{{n_f}+{n_m}}}}}{\partial\beta_2} \\
\end{array}\right]^T$
= 
$\left[\begin{array}{cccc|cccc}
1 & 1 & ... & 1 & 1 & 1 & ... & 1 \\
0 & 0 & ... & 0 & 1 & 1 & ... & 1 \\
\end{array}\right]^T$
Some thoughts:
Given your equation $\beta_1$ IMHO should be 175 and $\beta_2$ = -10. So for the male and female part you get:
$f_m = 175 (+) -10 \times 0 + u = 175 + u$
$f_f = 175 (+) -10 \times 1 + u = 165 + u$
Since you can use
$\mathbf{\beta} = \left(X'X\right)^{-1}X^{T}\mathbf{y}$ 
to solve for $\beta$ by using the Moore-Penrose Pseudoinverse.
$\left(\left(X'X\right)^{-1}X^{T}\right)^{+}\beta=\left(\left(X'X\right)^{-1}X^{T}\right)^{+}\begin{bmatrix}
175 \\
-10 
\end{bmatrix}=\mathbf{y}$
Now $\mathbf{y}$ contains:
$\mathbf{y}
 \approx \begin{bmatrix}
165_{f_1} & 165_{f_2} & ... 165_{f_{100}} & 175_{m_1} & 175_{m_2} & ... 175_{m_{100}}
\end{bmatrix}^T$
Hope it helps!
