Wikipedia says the standard way to estimate the parameter covariance $M^\beta$ for weighted least squares (WLS) is $$ M^\beta = \chi_\nu^2 (X^TWX)^{-1} $$ with $$ \chi_\nu^2=\frac{r^TWr}{\nu} $$ and the degrees of freedom $$ \nu=n-m $$ (n=number of samples, m=number of fitted parameters, r=residuals, W=diagonal weight matrix, X=data).
My question is about the formula for the degrees of freedom, i.e., the normalization of the reduced chi squared statistic.
Assume I have a bunch of samples with weights 1 and only one with weight 2. Since in WLS, weights correspond to the sample measurement precision, this should be the exact same scenario as simply observing the sample with weight 2 twice (independently).* Thus, WLS can be "emulated" by doing OLS with an extra repeated measurement sample. This yields identical parameter values $\beta$ but, using the above formula for the degrees of freedom, a different $\chi_\nu^2$.
I can achieve equivalence of the two parameter covariance estimates by choosing
$$
\nu = \text{sum(diag(}W)) - m,
$$
i.e., replacing $n$ in the formula by the sum of the weights. (This obviously reduces to the standard case for all-unit weights.) However, I am confused that the standard formula (which is also the one implemented by, e.g., lm
in R and fitlm
in Matlab) does not seem to "work" for this simple test case. What am I missing or misunterstanding?
There are many related questions already, e.g., on DOFs or on weighted sample variances.
*Precisions of multiple Gaussian observations are additive... two observations with the same mean and precision 1 are equivalent to one observation with precision 2. The only clear reference for this I could find is this paper, Table 2, Eq. (II.1).