Location-scale invariant simulation test for a Gaussian variance component (source code)

= Location-scale invariant simulation test for a Gaussian variance component

With fixed $X,Z$, compare $N(X\beta,\sigma^2I)$ and $N(X\beta,\sigma^2I+\tau^2ZZ^T)$ by maximizing the ordinary <likelihood function> in both models. Their <likelihood-ratio test statistic> is unchanged by $Y\mapsto Xb+cY$, $c>0$, because both maximized log-likelihoods change by the same $-n\log c$. Its null law can therefore be simulated using independent $N(0,I)$ responses. Comparing the observed statistic with simulated statistics by $(1+\#\{T_b\geq T_{obs}\})/(B+1)$ gives a conservative finite-sample Monte Carlo p-value, subject to correctly maximizing both likelihoods.