# Two sample test for both equal variance and mean

For two normally distributed samples, is there a way to test for $H_0: \mu_1=\mu_2$ and also $\sigma_1^2=\sigma_2^2$. I have computed the likelihood ratio, but cannot recognize the underlying distribution.

• FYI, you should test for the equality of variances prior to testing $\mu_1=\mu_2$ so you know which two-sample test is required. – Ken Apr 30 '12 at 15:43
• @Ken, you could do that, but I think he's asking how to jointly test them both with a single hypothesis test. – Macro Apr 30 '12 at 15:46
• Yes, it has to be a single test. – SamuelJ Apr 30 '12 at 18:00
• @Ken, whoever told you that is badly out of date (and wrong, which is worse). See, for example Zimmerman 2004 "A note on preliminary tests of equality of variances" or Rasch 2009 "The two-sample t test: pre-testing its assumptions does not pay off". If you don't have a reason to suppose the variances are equal, use the unequal variance version of the t-test. SamuelJ, you could compute the LR statistic and use it in a permutation test, that would work, if perhaps inelegantly. – guest May 1 '12 at 4:46

You could do a likelihood ratio test. Calculate the MLE for each data set separately:

$$L_1 \equiv \max_{\mu_{1}, \sigma_{1}} L_{1}(\mu_{1}, \sigma_{1})$$

$$L_2 \equiv \max_{\mu_{2}, \sigma_{2}} L_{2}(\mu_{2}, \sigma_{2})$$

where $L_1$ is the log-likelihood function for the first data set and $L_2$ is the log-likelihood function for the second. Then, if the two data sets are independent, the maximized log-likelihood for the full data set (i.e. the two data sets together) is $L_1 + L_2$. This is the maximized log-likelihood when the two data sets are not restricted to having the same mean and variance.

Now, to get the MLE under the constraint that the two populations do have the same mean, you calculate

$$L_{0} = \max_{\mu, \sigma} L(\mu, \sigma)$$

where $L$ is the log-likelihood function for the full data set. Then, under the null hypothesis you specified in your question,

$$\lambda = 2 \bigg( (L_1 + L_2) - L_0 \bigg)$$

has an approximate (i.e. asymptotic) $\chi^2$ distribution on 2 degrees of freedom, assuming that the null hypothesis being tested doesn't include $\sigma_1 = \sigma_2 = 0$, which clearly can't be the case if you observe non-zero variance in your data. You can use that null distribution for significance testing.

Note: The joint MLE for the normally distributed data is the sample mean:

$$\hat{\mu} = \frac{1}{n} \sum_{i=1}^{n} X_i$$

and the sample variance:

$$\hat{\sigma}^{2} = \frac{1}{n} \sum_{i=1}^{n} (X_i-\hat{\mu})^2$$

• I need to find the exact distribution, not an approximate distribution. It will depend on the actual likelihoods and $S_{XX}, S_{YY}, \bar{x}-\bar{y}$. – SamuelJ Apr 30 '12 at 16:02
• So, you're asking for the exact distribution of the (log) likelihood ratio in finite samples? This might be very complicated. I'd suggest a permutation test or looking at literature for special cases where the exact distribution of the likelihood ratio is derived and try to mimic the proof (e.g. jstor.org/stable/10.2307/2336564). – Macro Apr 30 '12 at 16:06
• If you have a decent sample size, this approximation will be good. If you have a small sample size, I'd suggest a permutation test based on permuting the group labels and repeating to get the permutation distribution of the log likelihood ratio, which should be a good approximation of the actual sampling distribution of the likelihood ratio. – Macro Apr 30 '12 at 16:07
• @Macro: (1) Until $\lambda$ is introduced, $L_0$, $L_1$, and $L_2$ are explicitly named as "likelihoods." After that, though, you appear to be using them as log likelihoods. (2) What do you mean by "$\sigma_1 =\sigma_2 = 0$ ... has probability 0"? Likelihoods are not probability distributions for parameters. – whuber Apr 30 '12 at 20:00
• thanks @whuber. I fixed these inconsistencies. All meant regarding the $\sigma_{1}=\sigma_{2}=0$ thing was that the likelihood ratio test is not valid when the null hypothesis is on the boundary of the parameter space, which it isn't in this case, unless both variances are 0, which they can't be if you observe variation in the data sets. – Macro Apr 30 '12 at 20:25