
MATH 4720/MSSC 5720 Introduction to Statistics
Often faced with a comparison of parameters from different populations.
Comparing the mean annual income for Male and Female groups.
Testing if a diet used for losing weight is effective from Placebo and New Diet samples.
Two samples are dependent or matched pairs if the sample values are matched, where the matching is based on some inherent relationship.
Height data of fathers and daughters. The height of each dad is matched with the height of his daughter.
Weights of subjects measure before and after some diet treatment. The subjects are the same before and after measurements.

| Subject | (Dad) Before | (Daughter) After |
|---|---|---|
| 1 | \(x_{b1}\) | \(x_{a1}\) |
| 2 | \(x_{b2}\) | \(x_{a2}\) |
| 3 | \(x_{b3}\) | \(x_{a3}\) |
| \(\vdots\) | \(\vdots\) | \(\vdots\) |
| \(n\) | \(x_{bn}\) | \(x_{an}\) |

Two samples are independent if the sample values from one population are not related to the sample values from the other.

| Subject of Group 1 (Male) | Measurement of Group 1 | Subject of Group 2 (Female) | Measurement of Group 2 |
|---|---|---|---|
| 1 | \(x_{11}\) | 1 | \(x_{21}\) |
| 2 | \(x_{12}\) | 2 | \(x_{22}\) |
| 3 | \(x_{13}\) | 3 | \(x_{23}\) |
| \(\vdots\) | \(\vdots\) | \(\vdots\) | \(\vdots\) |
| \(n_1\) | \(x_{1n_1}\) | \(\vdots\) | \(\vdots\) |
| \(n_2\) | \(x_{2n_2}\) |
\(\text{CI = point estimate} \pm \text{margin of error (E)}\), e.g., \(\overline{x} \pm t_{\alpha/2, n-1} \frac{s}{\sqrt{n}}\)
Margin of error = critical value \(\times\) standard error of the point estimator
To analyze a paired data set, simply analyze the differences!
| Subject | \(x_1\) | \(x_2\) | Difference \(d = x_1 - x_2\) |
|---|---|---|---|
| 1 | \(x_{11}\) | \(x_{21}\) | \(\color{red}{d_1}\) |
| 2 | \(x_{12}\) | \(x_{22}\) | \(\color{red}{d_2}\) |
| 3 | \(x_{13}\) | \(x_{23}\) | \(\color{red}{d_3}\) |
| \(\vdots\) | \(\vdots\) | \(\vdots\) | \(\color{red}{\vdots}\) |
| \(n\) | \(x_{1n}\) | \(x_{2n}\) | \(\color{red}{d_n}\) |
\(\mu_d = \mu_1 - \mu_2\)
\(\begin{align} & H_0: \mu_1 - \mu_2 = 0 \iff \mu_d = 0 \\ & H_1: \mu_1 - \mu_2 > 0 \iff \mu_d > 0 \\ & H_1: \mu_1 - \mu_2 < 0 \iff \mu_d < 0 \\ & H_1: \mu_1 - \mu_2 \ne 0 \iff \mu_d \ne 0 \end{align}\)
The point estimate of \(\mu_1 - \mu_2\) is \(\overline{x}_1 - \overline{x}_2 = \overline{d}\).
Requirements: the sample differences \(\color{blue}{d_i}\)s are
Follow the same procedure as the one-sample \(t\)-test!
The test statistic is \(\color{blue}{t_{test} = \frac{\overline{d}-0}{s_d/\sqrt{n}}} \sim T_{n-1}\) under \(H_0\) where \(\overline{d}\) and \(s_d\) are the mean and SD of the difference samples \((d_1, d_2, \dots, d_n)\).
The critical value \(t_{\alpha, n-1}\) and \(t_{\alpha/2, n-1}\).
| Paired \(t\)-test | Test Statistic | Confidence Interval for \(\mu_d = \mu_1 - \mu_2\) |
|---|---|---|
| \(\sigma_d\) is unknown | \(\large t_{test} = \frac{\overline{d}}{s_d/\sqrt{n}}\) | \(\large \overline{d} \pm t_{\alpha/2, n-1} \frac{s_d}{\sqrt{n}}\) |
Consider a capsule used to reduce blood pressure (BP) for the hypertensive individuals. Sample of 10 hypertensive individuals take the medicine for 4 weeks.
Does the data provide sufficient evidence that the treatment is effective in reducing BP?
| Subject | Before \((x_b)\) | After \((x_a)\) | Difference \(d = x_b - x_a\) |
|---|---|---|---|
| 1 | 143 | 124 | 19 |
| 2 | 153 | 129 | 24 |
| 3 | 142 | 131 | 11 |
| 4 | 139 | 145 | -6 |
| 5 | 172 | 152 | 20 |
| 6 | 176 | 150 | 26 |
| 7 | 155 | 125 | 30 |
| 8 | 149 | 142 | 7 |
| 9 | 140 | 145 | -5 |
| 10 | 169 | 160 | 9 |

\(\overline{d} = 13.5\), \(s_d= 12.48\).
\(\mu_1 =\) Mean Before, \(\mu_2 =\) Mean After, and \(\mu_d = \mu_1 - \mu_2\).
The 95% CI for \(\mu_d = \mu_1 - \mu_2\) is \[\begin{align}\overline{d} \pm t_{\alpha/2, df} \frac{s_d}{\sqrt{n}} &= 13.5 \pm t_{0.025, 9}\frac{12.48}{\sqrt{10}}\\ &= 13.5 \pm 8.927 \\ &= (4.573, 22.427).\end{align}\]
95% confident that the mean difference in blood pressure is between 4.57 and 22.43.
Since the interval does NOT include 0, it leads to the same conclusion as rejection of \(H_0\).
pair_data before after
1 143 124
2 153 129
3 142 131
4 139 145
5 172 152
6 176 150
7 155 125
8 149 142
9 140 145
10 169 160
## t.test() function
t.test(x = pair_data$before, y = pair_data$after, alternative = "greater", mu = 0, paired = TRUE)
Paired t-test
data: pair_data$before and pair_data$after
t = 3, df = 9, p-value = 0.004
alternative hypothesis: true mean difference is greater than 0
95 percent confidence interval:
6.3 Inf
sample estimates:
mean difference
14
Whether stem cells can improve heart function.
The relationship between pregnant womens’ smoking habits and newborns’ weights.
Whether one variation of an exam is harder than another variation.



Requirements:
The two samples are independent.
Both samples are a random sample.
\(n_1 > 30\), \(n_2 > 30\) and/or both samples are from a normally distributed population.
Interested in whether the two population means \(\mu_1\) and \(\mu_2\) are equal or not, or one is larger than the other.
\(H_0: \mu_1 = \mu_2\)
It is equivalent to testing if their difference is zero.
\(H_0: \mu_1 - \mu_2 = 0\)
We start with finding a point estimate for \(\mu_1 - \mu_2\). What is the best point estimator for \(\mu_1 - \mu_2\)?
\(\overline{X}_1 - \overline{X}_2\) is the best point estimator for \(\mu_1 - \mu_2\)!
If the two samples are from independent normally distributed populations or \(n_1 > 30\) and \(n_2 > 30\), \[\small \overline{X}_1 \sim N\left(\mu_1, \frac{\sigma_1^2}{n_1} \right), \quad \overline{X}_2 \sim N\left(\mu_2, \frac{\sigma_2^2}{n_2} \right)\]
\(\overline{X}_1 - \overline{X}_2\) has the sampling distribution \[\small \overline{X}_1 - \overline{X}_2 \sim N\left(\mu_1 - \mu_2, \frac{\sigma_1^2}{n_1} {\color{red}{+}} \frac{\sigma_2^2}{n_2} \right) \]
\[\small Z = \frac{(\overline{X}_1 - \overline{X}_2) - (\mu_1 - \mu_2)}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}} \sim N(0, 1)\]
With \(D_0\) a hypothesized value (often 0),
\(\small \begin{align} &H_0: \mu_1 - \mu_2 \le D_0\\ &H_1: \mu_1 - \mu_2 > D_0 \end{align}\) (right-tailed)
\(\small \begin{align} &H_0: \mu_1 - \mu_2 \ge D_0\\ &H_1: \mu_1 - \mu_2 < D_0 \end{align}\) (left-tailed)
\(\small \begin{align} &H_0: \mu_1 - \mu_2 = D_0\\ &H_1: \mu_1 - \mu_2 \ne D_0 \end{align}\) (two-tailed)
If \(\sigma_1\) and \(\sigma_2\) are known, the test statistic is the z-score of \(\small \overline{X}_1 - \overline{X}_2\) under \(H_0\): \[z_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - (\mu_1 - \mu_2)}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}} \]
Then find \(z_{\alpha}\) or \(z_{\alpha/2}\) and follow our testing steps!
\[t_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - (\mu_1 - \mu_2)}{\sqrt{\frac{\color{red}{s_1^2}}{n_1} + \frac{\color{red}{s_2^2}}{n_2}}} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{\sqrt{\frac{\color{red}{s_1^2}}{n_1} + \frac{\color{red}{s_2^2}}{n_2}}} \]
| \(\large \color{red}{\sigma_1 \ne \sigma_2}\) | Test Statistic | Confidence Interval for \(\mu_1 - \mu_2\) |
|---|---|---|
| known | \(\large z_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}}\) | \(\large (\overline{x}_1 - \overline{x}_2) \pm z_{\alpha/2} \sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}\) |
| unknown | \(\large t_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{\sqrt{\frac{\color{red}{s_1^2}}{n_1} + \frac{\color{red}{s_2^2}}{n_2}}}\) | \(\large (\overline{x}_1 - \overline{x}_2) \pm t_{\alpha/2, df} \sqrt{\frac{\color{red}{s_1^2}}{n_1} + \frac{\color{red}{s_2^2}}{n_2}}\) |
Use \(\small df = \dfrac{(A+B)^2}{\dfrac{A^2}{n_1-1}+ \dfrac{B^2}{n_2-1}},\) where \(\small A = \dfrac{s_1^2}{n_1}\) and \(\small B = \dfrac{s_2^2}{n_2}\) to get the \(p\)-value, critical value, and CI.
The unequal-variance t-test is called Welch’s t-test.
Does an oversized tennis racket exert less stress/force on the elbow? The data show
Oversized: \(n_1 = 33\), \(\overline{x}_1 = 25.2\), \(s_1 = 8.6\)
Conventional: \(n_2 = 12\), \(\overline{x}_2 = 33.9\), \(s_2 = 17.4\)
The two populations are nearly normal.
The large difference in the sample SD suggests \(\sigma_1 \ne \sigma_2\).
Form a hypothesis test with \(\alpha = 0.05\) and construct a 95% CI for the mean difference of force on the elbow.

\(\small A = \dfrac{8.6^2}{33}\), \(\small B = \dfrac{17.4^2}{12}\), \(\small df = \dfrac{(A+B)^2}{\dfrac{A^2}{33-1}+ \dfrac{B^2}{12-1}} = 13.01\)
If the computed value of \(df\) is not an integer, always round down to the nearest integer.
Step 4-c: \(-t_{0.05, 13} = -1.77\).
Step 5-c: We reject \(H_0\) if \(\small t_{test} < -t_{\alpha, df}\). \(\small t_{test} = -1.66 > -1.77 = -t_{\alpha, df}\), we fail to reject \(H_0\).
Step 6: There is insufficient evidence to support the claim that the oversized racket delivers less stress to the elbow.
\[\begin{align}(\overline{x}_1 - \overline{x}_2) \pm t_{\alpha/2, df} \sqrt{\frac{\color{red}{s_1^2}}{n_1} + \frac{\color{red}{s_2^2}}{n_2}} &= (25.2 - 33.9) \pm t_{0.025,13}\sqrt{\frac{8.6^2}{33} + \frac{17.4^2}{12}}\\&= -8.7 \pm 11.32 = (-20.02, 2.62).\end{align}\]
We are 95% confident that the difference in the mean forces is between -20.02 and 2.62.
Since the interval includes 0, it leads to the same conclusion as failing to reject \(H_0\).
n1 = 33; x1_bar = 25.2; s1 = 8.6
n2 = 12; x2_bar = 33.9; s2 = 17.4
A <- s1^2 / n1; B <- s2^2 / n2
df <- (A + B)^2 / (A^2/(n1-1) + B^2/(n2-1))
(df <- floor(df))[1] 13
## t_test
(t_test <- (x1_bar - x2_bar) / sqrt(s1^2/n1 + s2^2/n2))[1] -1.7
## t_cv
qt(p = 0.05, df = df)[1] -1.8
## p_value
pt(q = t_test, df = df)[1] 0.06
\[z_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - (\mu_1 - \mu_2)}{\sigma\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{\sigma\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}} \]
If \(\sigma_1\) and \(\sigma_2\) are unknown, similar to the one sample case, we use \(t_{test}\).
As \(\sigma_1 = \sigma_2 = \sigma\), we don’t need two but one sample SD to replace the \(\sigma\).
Use the pooled sample variance to estimate the common \(\sigma^2\):
\[ s_p^2 = \frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2} \] which is the weighted average of \(s_1^2\) and \(s_2^2\).
If \(\sigma_1\) and \(\sigma_2\) are unknown, \[t_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - (\mu_1 - \mu_2)}{ {\color{red}{s_p}}\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{{\color{red}{s_p}}\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}\]
Here, the critical value \(t_{\alpha, df}\) (for one-tailed tests) and \(t_{\alpha/2, df}\) (for two-tailed tests), and the \(t\) distribution used to compute the \(p\)-value have the degrees of freedom \[df = n_1 + n_2 - 2\]
| \(\large \color{red}{\sigma_1 = \sigma_2}\) | Test Statistic | Confidence Interval for \(\mu_1 - \mu_2\) |
|---|---|---|
| known | \(\large z_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{\sigma\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}\) | \(\large (\overline{x}_1 - \overline{x}_2) \pm z_{\alpha/2} \sigma \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}\) |
| unknown | \(\large t_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{{\color{red}{s_p}}\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}\) | \(\large (\overline{x}_1 - \overline{x}_2) \pm t_{\alpha/2, df} {\color{red}{s_p}}\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}\) |
\(s_p = \sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2}}\)
Use \(df = n_1+n_2-2\) get the \(p\)-value, critical value and CI.
The test from two independent samples with \(\sigma_1 = \sigma_2 = \sigma\) is usually called two-sample pooled \(z\)-test or two-sample pooled \(t\)-test.
A study was conducted to see the effectiveness of a weight loss program.
Two groups (Control and Experimental) of 10 subjects were selected.
The two populations are normally distributed and have the same SD.

The data on weight loss was collected at the end of six months
Is there a sufficient evidence at \(\alpha = 0.05\) to conclude that the program is effective?
If yes, construct a 95% CI for \(\mu_1 - \mu_2\) to show how much effective it is.
Step 3: \(t_{test} = \frac{(\overline{x}_1 - \overline{x}_2) - \color{blue}{D_0}}{{\color{red}{s_p}}\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}\).
\(s_p = \sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2}} = \sqrt{\frac{(10-1)0.5^2 + (10-1)0.7^2}{10+10-2}}=0.61\)
\(t_{test} = \frac{(2.1 - 4.2) - 0}{0.6083\sqrt{\frac{1}{10} + \frac{1}{10}}} = -7.72\)
The 95% CI for \(\mu_1 - \mu_2\) is \[\begin{align}(\overline{x}_1 - \overline{x}_2) \pm t_{\alpha/2, df} {\color{red}{s_p}}\sqrt{\frac{1}{n_1} + \frac{1}{n_2}} &= (2.1 - 4.2) \pm t_{0.025, 18} (0.61)\sqrt{\frac{1}{10} + \frac{1}{10}}\\ &= -2.1 \pm 0.57 = (-2.67, -1.53) \end{align}\]
We are 95% confident that the difference in the mean weight loss is between -2.67 and -1.53.
Since the interval does not include 0, it leads to the same conclusion as rejection of \(H_0\).
n1 = 10; x1_bar = 2.1; s1 = 0.5
n2 = 10; x2_bar = 4.2; s2 = 0.7
sp <- sqrt(((n1 - 1) * s1 ^ 2 + (n2 - 1) * s2 ^ 2) / (n1 + n2 - 2))
sp[1] 0.61
df <- n1 + n2 - 2
## t_test
(t_test <- (x1_bar - x2_bar) / (sp * sqrt(1 / n1 + 1 / n2)))[1] -7.7
## t_cv
qt(p = 0.05, df = df)[1] -1.7
## p_value
pt(q = t_test, df = df)[1] 2e-07