Two sample t test with unknown and equal variances
In this tutorial we will discuss two sample t-test for testing difference between two population means when the population variances are unknown but equal.
Two sample t test with unknown and equal variances
Let $\overline{x}_1$
be the sample mean and $s_1$ be the sample standard deviation of a random sample of size $n_1$ from a population with mean $\mu_1$ and variance $\sigma^2_1$
.
Let $\overline{x}_2$
be the sample mean and $s_2$ be the sample standard deviation of a random sample of size $n_2$ from a population with mean $\mu_2$ and variance $\sigma^2_2$
.
Suppose the variances $\sigma^2_1$ and $\sigma^2_2$ are unknown but equal.
Assumptions
Assumptions for two sample $t$-test are as follows:
a. The population from which, the two samples drawn are Normal distributions.
b. The two population variances are unknown but equal.
Procedure
We wish to test the hypothesis $H_0 : \mu_1 = \mu_2$.
The standard error of difference between means is
$$ SE(\overline{x}_1-\overline{x}_2) = s_p\sqrt{\frac{1}{n_1}+ \frac{1}{n_2}} $$
where $s_p$ is the pooled standard deviation and is given by
$$ s_p =\sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2}}. $$
Step by Step Procedure
The step by step hypothesis testing procedure is as follows:
Step 1 State the hypothesis testing problem
The hypothesis testing problem can be structured in any one of the three situations as follows:
Situation | Hypothesis Testing Problem |
---|---|
Situation A : | $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 < \mu_2$ (Left-tailed) |
Situation B : | $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 > \mu_2$ (Right-tailed) |
Situation C : | $H_0: \mu_1=\mu_2$ against $H_a : \mu_1 \neq \mu_2$ (Two-tailed) |
Step 2 Define the test statistic
The test statistic for testing above hypothesis is
$$ \begin{eqnarray*} t & =& \frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{SE(\overline{x}_1-\overline{x}_2)}\\\\ & =& \frac{(\overline{x}_1-\overline{x}_2)-(\mu_1-\mu_2)}{s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}} \end{eqnarray*} $$
The test statistic $t$ follows Students’ $t$ distribution with $n_1+n_2-2$ degrees of freedom.
Step 3 Specify the level of significance $\alpha$
Step 4 Determine the critical values
For the specified value of $\alpha$ determine the critical region depending upon the alternative hypothesis.
- For left-tailed alternative hypothesis: Find the $t$-critical value using
$$ \begin{aligned} P(t<-t_\alpha) = \alpha. \end{aligned} $$
- For right-tailed alternative hypothesis: $t_\alpha$.
$$ \begin{aligned} P(t>t_\alpha) = \alpha. \end{aligned} $$
- For two-tailed alternative hypothesis: $t_{\alpha/2}$.
$$ P(t<-t_{\alpha/2} \text{ or } t> t_{\alpha/2}) = \alpha. $$
Step 5 Computation
Compute the test statistic under the null hypothesis $H_0$ using equation
$$ \begin{aligned} t_{obs} &= \frac{(\overline{x}_1-\overline{x}_2)-0}{s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}} \end{aligned} $$
Step 6 Decision (Traditional Approach)
It is based on the critical values.
- For left-tailed alternative hypothesis: Reject $H_0$ if
$t_{obs}\leq -t_\alpha$
. - For right-tailed alternative hypothesis: Reject $H_0$ if
$t_{obs}\geq t_\alpha$
. - For two-tailed alternative hypothesis: Reject $H_0$ if
$|t_{obs}|\geq t_{\alpha/2}$
.
OR
Step 6 Decision ($p$-value Approach)
It is based on the $p$-value.
Alternative Hypothesis | Type of Hypothesis | $p$-value |
---|---|---|
$H_a: \mu_1<\mu_2$ | Left-tailed | $p$-value $= P(t\leq t_{obs})$ |
$H_a: \mu_1>\mu_2$ | Right-tailed | $p$-value $= P(t\geq t_{obs})$ |
$H_a: \mu_1\neq \mu_2$ | Two-tailed | $p$-value $= 2P(t\geq abs(t_{obs}))$ |
If $p$-value is less than $\alpha$, then reject the null hypothesis $H_0$ at $\alpha$ level of significance, otherwise fail to reject $H_0$ at $\alpha$ level of significance.