In a regression model estimated with $n$ observations, $$y_i = \beta_0 +\beta_1 x_{1i}+...+\beta_k x_{ki} +u_i$$ the baseline degrees of freedom adjustment when calculating standard errors is to multiply the squared residuals, $\hat{u_i}^2$, by $\frac{n}{n-k-1}$. I know the derivation for this.
Suppose there is clustering with $G$ groups for which $Cov(u_i,u_j)\ne 0$ if and only if $i$ and $j$ are in the same group. Let $\hat{u_g}$ denote the column vector of residuals from group $g$. The degrees of freedom adjustment is to multiply $\hat{u_g}\hat{u_g}'$ by $\frac{n-1}{n-k-1} \frac{G}{G-1}$. I know this result (Green's Econometric Analysis presents this without proof), but I have not seen a derivation for it.
I am hoping for either a derivation of that adjustment or a reference to a derivation.