## Paired $t$-test (Dependent Sample)

Let $X_1, X_2, \cdots, X_n$ and $Y_1, Y_2, \cdots, Y_n$ be two dependent samples each of size $n$ with respective means $\mu_1$ and $\mu_2$.

Define $d_i = X_i - Y_i$, $i=1,2,\cdots, n$. Then $\mu_d= \mu_1 - \mu_2$.

Let $\overline{d}=\frac{1}{n} \sum d_i$ be the mean of the difference and $s_d=\sqrt{\frac{1}{n-1}\sum (d_i - \overline{d})^2}$ be the sample standard deviation of the difference.

## Assumptions

a. The samples are dependent (matched pairs).

b. Both the samples are simple random sample.

c. The two samples are both large ($n_1 > 30$ and $n_2 >30$) or both the samples comes from population having normal distribution.

## Step by Step Procedure

We wish to test the hypothesis $H_0: \mu_1 = \mu_2$, i.e., $H_0:\mu_d=0$.

The standard error of $\overline{d}$ is

```
$$
\begin{aligned}
SE(\overline{d}) = \frac{s_d}{\sqrt{n}}
\end{aligned}
$$
```

where $s_d$ is the sample standard deviation of the difference $d_i$.

### 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_d=0$ against $H_a : \mu_d < 0$ (Left-tailed) |

Situation B | $H_0: \mu_d=0$ against $H_a : \mu_d > 0$ (Right-tailed) |

Situation C | $H_0: \mu_d=0$ against $H_a : \mu_d \neq 0$ (Two-tailed) |

### Step 2 Define the test statistic

The test statistic for testing above hypothesis is
```
$$
\begin{eqnarray*}
t & =& \frac{\overline{d}-\mu_d}{SE(\overline{d})}\\
& =& \frac{\overline{d}-\mu_d}{s_d/\sqrt{n}}
\end{eqnarray*}
$$
```

where $\overline{d} =\frac{1}{n}\sum d_i$ and $s_d=\sqrt{\frac{\sum (d_i -\overline{d})^2}{n-1}}$.

The test statistic defined above follows Students $t$ distribution with $n-1$ 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{d}-0}{s_d/\sqrt{n}}
\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.