# Can I use chi-square to test goodness-of-fit in a generalized least-squares regression?

I am performing a generalized least squares regression based on a design matrix $X$, a response vector $Y$ and a (non-diagonal) covariance matrix $C$, assuming Gaussian errors. I'm not sure what goodness-of-fit tests are applicable. As a first step I could go for a simple chi-squared approach, using the usual formula $\chi^2 = r^T C^{-1} r$, where $r$ is the vector of residuals, but:

1. Is this formula applicable to the case of a non-diagonal matrix $C$?
2. Can the generated $\chi^2$ statistic be used in the same way as if $C$ were diagonal (e.g., the weighted least squares case)
3. Are there better goodness-of-fit statistics that are more frequently used for a problem like this one?
• How do you know $C$? Nov 12 '20 at 16:31
• Known analytical uncertainties + classical error propagation rules. But I was asking in the general case. Jul 18 '21 at 16:50

If the residuals, $r$ have a known population covariance matrix $C$ then $r^TC^{-1}r\sim \chi_n^2$ as long as $r\sim \mathcal{N}(0, C)$, regardless of the structure of $C$. For a proof, Google "quadratic forms of random variables". So it has the exact same meaning as goodness-of-fit for weighted least squares and I don't see anything reason why you couldn't use it in a similar way. However, in my experience statistical packages will give you coefficient of determination as a goodness-of-fit statistic.
• Won't the coefficient of determination will be the same if I multiply $C$ by an arbitrary factor? My initial choice of $\chi^2$ was motivated by the need to estimate whether my assigned uncertainties ($C$) are sufficient to explain the fit residuals $r$. It seems to me that I'm losing that piece of information if I use $R^2$. Mar 23 '18 at 11:05