TITLE: Understanding degrees of freedom in relation to rank for $\sum_{i=1}^{n}(y_i-\bar{y})^2$
QUESTION [5 upvotes]: So I'm looking at this website which states:

One of the questions an instrutor [sic] dreads most from a mathematically unsophisticated audience is, "What exactly is degrees of freedom?" It's not that there's no answer. The mathematical answer is a single phrase, "The rank of a quadratic form."

And near the end:

Okay, so where's the quadratic form? Let's look at the variance of a single sample. If $y$ is an $n$ by $1$ vector of observations, then
  $$\sum(y_i - \bar{y})^2 = y^{\prime}My\text{, where }M = \begin{pmatrix}
1-\frac{1}{n} & -1/n & \cdot & -1/n \\
-1/n          & 1-\frac{1}{n} & \cdot & -1/n \\
\cdot         & \cdot         & \cdot & \cdot \\
-1/n          & -1/n          & -1/n & 1-\frac{1}{n}
\end{pmatrix}\text{.}$$
  The number of degrees of freedom is equal to the rank of the $n$ by $n$ matrix $M$, which is $n-1$.

I will use $r$ to denote the rank and $C(A)$ to denote the column space of a matrix $A$.
From my notes, I have the definition $r(A) = r\left(C(A)\right)$, which is the number of vectors that create a basis for $C(A)$. Sure.
Let's consider column one:
$$\begin{pmatrix}
1-\frac{1}{n}\\
-1/n \\
\cdot \\
-1/n
\end{pmatrix} = \dfrac{-1}{n}
\begin{pmatrix}
1-n \\
1 \\
\cdot \\
1 
\end{pmatrix} = \dfrac{-1}{n}\begin{pmatrix}
1 \\
1 \\
\cdot \\
1 
\end{pmatrix} + \dfrac{-1}{n}\begin{pmatrix}
-n \\
0 \\
\cdot \\
0 
\end{pmatrix} = \dfrac{-1}{n}\begin{pmatrix}
1 \\
1 \\
\cdot \\
1 
\end{pmatrix}+\begin{pmatrix}
1 \\
0 \\
\cdot \\
0 
\end{pmatrix}\text{.}
$$
So based on what I'm seeing here, I'm guessing that a basis for $C(A)$ would be something like 
$$\mathscr{V} = \left\{\begin{pmatrix}
1 \\
1 \\
\cdot \\
1 
\end{pmatrix}, \begin{pmatrix}
1 \\
0 \\
\cdot \\
0 
\end{pmatrix}, \begin{pmatrix}
0 \\
1 \\
\cdot \\
0 
\end{pmatrix}, \cdots, \begin{pmatrix}
0 \\
0 \\
\cdot \\
1 
\end{pmatrix}\right\}$$
which consists of $n+1$ vectors. However, clearly $$\begin{pmatrix}
1 \\
1 \\
\cdot \\
1 
\end{pmatrix}$$ needs to be removed, since it is the sum of the other $n$ vectors, so I get that there are $n$ vectors in $\mathscr{V}$, and therefore $r(\mathscr{V}) = r(C(M)) = n$.
Where is the $n-1$ coming from?

REPLY [3 votes]: Take en example: the matrix 
$$
A=\left[\matrix{1 & 1\\2 & 2}\right].
$$
Applying your method: the first column
$$
\left[\matrix{1 \\ 2}\right]=\left[\matrix{1 \\ 1}\right]+\left[\matrix{0 \\ 1}\right],
$$
and the second column
$$
\left[\matrix{1 \\ 2}\right]=2\left[\matrix{1 \\ 1}\right]-\left[\matrix{1 \\ 0}\right],
$$
hence, collecting all "basic" vectors
$$
\left\{\left[\matrix{1 \\ 1}\right],\left[\matrix{1 \\ 0}\right],\left[\matrix{0 \\ 1}\right]\right\}
$$
and removing the first dependent gives the rank being $2$.
Do you see the problem with your argument?

 The vectors you take as basic vectors do not all belong to the subspace. They span a larger subspace than $C(A)$.