# Understanding formulation of hypotheses in difference between two sample means (z test)

## Introduction

When testing a sample against a population, one has one of the following sets of hypotheses:

1. Two-tailed test: $H_0: \mu=\ldots$, i.e. "no difference", and $H_1: \mu\neq\ldots$

2. Right-tailed test: $H_0: \mu\leq\ldots$, and $H_1: \mu>\ldots$

3. Left-tailed test: $H_0: \mu\geq\ldots$, and $H_1: \mu<\ldots$

I know that some textbooks write $H_0: \mu=\ldots$, and $H_1: \mu>\ldots$ for one-tailed tests, i.e. leave out the other side. However, I always considered that bad practice.

Now suppose testing the difference between two sample means. Here, the formula states:

$z=\frac{(\bar{X}_1-\bar{X}_2)-(\mu_1-\mu2)}{\sqrt{\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}}}$

Then, it is assumed that $H_0:\mu_1=\mu_2$. Thus, we get:

$z=\frac{(\bar{X}_1-\bar{X}_2)}{\sqrt{\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}}}$

## Problem

This is all fine to me when considering two-tailed tests. However, I encountered an exercise that asks whether there is a significant increase between two samples (sales of first and second year).

Now I face two questions:

1. Isn't it correct to state $H_0: \mu_1\geq\mu_2$, and $H_1: \mu_1<\mu_2$ for a left-tailed test comparing two sample means? But then the $\mu$s would not sum to zero. I assume that this does not matter since if $\mu_1-\mu_2$ increases, in the formula, we would get a smaller $z$ which would lead us to rejecting $H_0$ with a higher probability anyway. Thus, every case is covered with $H_0:\mu_1=\mu_2$ already.

2. Since the two samples have "equal rights", referring to the symmetry between the samples, can we formulate the hypotheses either way, i.e. measure an increase of one or, alternatively, swap $H_0$ and $H_1$ and switch the equality signs? This is, of course, a no-go for "normal" tests, but facing two sample means, it does not matter which way to look at them, or does it?

1) If you want your hypotheses to partition the universe, where do you stop? Imagine you have a dataset drawn from a normal distribution. You might consider the hypotheses:

$H_1$: $\mu>0$

$H_0$: $\mu\leq0$

$H_{-1}$: The data weren't Normal after all but followed some other distribution

$H_{-2}$: The data didn't even have to be real valued, we just happened to observe nothing but real values

...

In practice, if the sample mean of population 2 is lower than that of population 1 we will always be rejecting an alternative hypothesis of $\mu_2 > \mu_1$ whether the null hypothesis contained an equals or a $"\leq"$.

It is perfectly possible to perform a likelihood ratio test for an "$=$" hypothesis against a "$<$" hypothesis.

2) Yes, you can swap the signs but you don't swap which hypothesis is the null. The two formulations are equivalent:

$H_0: \mu_1 \leq \mu_2\\H_1: \mu_1 > \mu_2$

$H_0: \mu_2 \geq \mu_1\\H_1: \mu_2 < \mu_1$

The reason for this is that the datasets were symmetric in a sense, but the null hypothesis enjoys a special privilege (it is "innocent until proven guilty", or at least 95%-so.)

• Nice idea ... $H_{-n}$ :-) Yes, I see — I cannot just swap hypothesis. I made a mistake there regarding my line of thought. Of course, it's different whether there's a decrease or an increase. Is it correct so say: $\mu_1-\mu_2=d$. Now if $d$ is negative, we are looking at your example hypotheses and consider a left-tailed test (negative z values). If $d$ is positive, we need to run a right-tailed test. Thus, it does matter what the hypotheses are? – Xiphias Aug 31 '16 at 13:28
• Ideally, you should formulate your hypotheses before you look at the data. If you were happy to consider either sided test based on what the data looked like, then you probably should have used a two-tailed test. – JDL Aug 31 '16 at 13:36
• True, but I only have the $X_1$ and $X_2$ sample datasets. So the difference $d$ is part of my hypothesis (stating what I believe the difference is). I think this is in line with what you said! – Xiphias Aug 31 '16 at 13:38
1. Your assumption is correct and you explained it nicely yourself.

2. If you swap the hypotheses, then you must keep in mind that level of significance $\alpha$ and 1-power will swap places.