# Testing nested models with clustered errors

I have a simple linear model. $$Y_i = \beta_1X _{1i}+ \beta_2X_{2i}+\beta_3X_{3i}+\epsilon_i$$

I'd like to test if some of my model parameters ($$\beta_2$$ and $$\beta_3$$) are jointly different from zero.

This post gives a nice overview of how the different tests (Wald, Likelihood Ratio and Score) can be used to determine the significance of such nested models. However, it's not clear to me that the Likelihood ratio test is still appropriate in the case that I need to cluster my standard errors.

In the case of clustering with $$G$$ groups, my covariance matrix is will be different and the Wald Test incorporates this, both because the calculation uses the covariance matrix and critical value is now determined from an F-distribution with reduced denominator degrees of freedom ($$G-1$$) as opposed to the number of observations. However, since my parameter estimates remain unchanged, the residual sum of squares remains unchanged, so the Likehood Ratio will remain unchanged. Stata and python's statsmodels will report the same Log-Likelihood for the models regardless of clustering, which is still based on the number of observations, not the number of groups.

So is it completely wrong to use the Likelihood Ratio in this case?

So is it completely wrong to use the Likelihood Ratio in this case?

Saying "completely wrong" is too strong, because it might still have in some cases better small sample properties than a cluster robust Wald test. Cluster robust Wald test overrejects in many cases in small samples.
However, the Likelihood Ratio test is not valid if there is cluster correlation or other correlation or heteroscedasticity that is not included in the model.

In the linear exponential family, including the linear gaussian model, the parameter estimates for the mean function are consistently estimated even if variance and correlation are misspecified.

Wald test can still be based on asymptotically correct standard errors if a Goddambe-Eicker-Huber-White sandwich covariance estimate is used.

There is also a corrected version of the score test, that is the analogue of a sandwich based Wald test and takes unspecified correlation or heteroscedasticity into account. (A preliminary version of this score_test is in statsmodels master.)

However, the likelihood ratio test assumes that the likelihood function is correctly specified. If that is not the case, then the distribution of the test statistic is not the usual chi-square distribution. Consequently the standard likelihood ratio test is invalid.
The distribution of the LR test statistic in many cases is the same as a weighted sum of chisquare distribution. The weights and an approximation to this distribution can be computed in some special cases, where the weights are model specific.
There are a few special cases where the LR test still has a chisquare distribution in misspecified case, a main example is quasi-likelihood in generalized linear models like Poisson with simple over or under dispersion.

Instead of proper references, some links to statsmodels issues which include many of the references for related questions that I looked, e.g. Wooldridge, Cameron and Trivedi and Boos and Stefanski.
https://github.com/statsmodels/statsmodels/issues/3363 https://github.com/statsmodels/statsmodels/issues/1755 https://github.com/statsmodels/statsmodels/issues/1163#issuecomment-48189874 https://github.com/statsmodels/statsmodels/issues/2054