Skip to main content

Introductory Statistics

Section 7.2 Paired data

In an earlier edition of this textbook, we found that Amazon prices were, on average, lower than those of the UCLA Bookstore for UCLA courses in 2010. Itโ€™s been several years, and many stores have adapted to the online market, so we wondered, how is the UCLA Bookstore doing today?
We sampled 201 UCLA courses. Of those, 68 required books could be found on Amazon. A portion of the data set from these courses is shown in Figureย 7.2.1, where prices are in US dollars.
subject course number bookstore amazon price difference
1 American Indian Studies M10 47.97 47.45 0.52
2 Anthropology 2 14.26 13.55 0.71
3 Arts and Architecture 10 13.50 12.53 0.97
\(\vdots\) \(\vdots\) \(\vdots\) \(\vdots\) \(\vdots\) \(\vdots\)
68 Jewish Studies M10 35.96 32.40 3.56
Figure 7.2.1. Four cases of the textbooks data set.

Subsection 7.2.1 Paired observations

Each textbook has two corresponding prices in the data set: one for the UCLA Bookstore and one for Amazon. When two sets of observations have this special correspondence, they are said to be paired.

Paired data.

Two sets of observations are paired if each observation in one set has a special correspondence or connection with exactly one observation in the other data set.
To analyze paired data, it is often useful to look at the difference in outcomes of each pair of observations. In the textbook data, we look at the differences in prices, which is represented as the price_difference variable in the data set. Here the differences are taken as
\begin{equation*} \text{UCLA Bookstore price} - \text{Amazon price} \end{equation*}
It is important that we always subtract using a consistent order; here Amazon prices are always subtracted from UCLA prices. The first difference shown in Figureย 7.2.1 is computed as \(47.97 - 47.45 = 0.52\text{.}\) Similarly, the second difference is computed as \(14.26 - 13.55 = 0.71\text{,}\) and the third is \(13.50 - 12.53 = 0.97\text{.}\) A histogram of the differences is shown in Figureย 7.2.2. Using differences between paired observations is a common and useful way to analyze paired data.
A histogram is shown for "UCLA bookstore Price minus Amazon Price, in US dollars", where values range from -$20 to positive $80. The distribution has a prominent peak at or slightly above $0, with the wide majority of data lying between -$20 and positive $20. There are also 4 bins above $20 that have non-zero heights: bin $20 to $30 has a height of 2, bin $30 to $40 has a height of 2, bin $50 to $60 has a height of 1, and bin $70 to $80 has a height of 1.
Figure 7.2.2. Histogram of the difference in price for each book sampled.

Subsection 7.2.2 Inference for paired data

To analyze a paired data set, we simply analyze the differences. We can use the same \(t\)-distribution techniques we applied in Sectionย 7.1.
\(n_{\text{diff}}\) \(\bar{x}_{\text{diff}}\) \(s_{\text{diff}}\)
68 3.58 13.42
Figure 7.2.3. Summary statistics for the 68 price differences.

Example 7.2.4.

Set up a hypothesis test to determine whether, on average, there is a difference between Amazonโ€™s price for a book and the UCLA bookstoreโ€™s price. Also, check the conditions for whether we can move forward with the test using the \(t\)-distribution.
Solution.
We are considering two scenarios: there is no difference or there is some difference in average prices.
  • \(H_0\text{:}\) \(\mu_{\text{diff}} = 0\text{.}\) There is no difference in the average textbook price.
  • \(H_A\text{:}\) \(\mu_{\text{diff}} \neq 0\text{.}\) There is a difference in average prices.
Next, we check the independence and normality conditions. The observations are based on a simple random sample, so independence is reasonable. While there are some outliers, \(n = 68\) and none of the outliers are particularly extreme, so the normality of \(\bar{x}\) is satisfied. With these conditions satisfied, we can move forward with the \(t\)-distribution.

Example 7.2.5.

Complete the hypothesis test started in Exampleย 7.2.4.
Solution.
To compute the test statistic, we compute the standard error associated with \(\bar{x}_{\text{diff}}\) using the standard deviation of the differences (\(s_{\text{diff}} = 13.42\)) and the number of differences (\(n_{\text{diff}} = 68\)):
\begin{equation*} SE_{\bar{x}_{\text{diff}}} = \frac{s_{\text{diff}}}{\sqrt{n_{\text{diff}}}} = \frac{13.42}{\sqrt{68}} = 1.63 \end{equation*}
The test statistic is the T-score of \(\bar{x}_{\text{diff}}\) under the null condition that the actual mean difference is 0:
\begin{equation*} T = \frac{\bar{x}_{\text{diff}} - 0}{SE_{\bar{x}_{\text{diff}}}} = \frac{3.58 - 0}{1.63} = 2.20 \end{equation*}
To visualize the p-value, the sampling distribution of \(\bar{x}_{\text{diff}}\) is drawn as though \(H_0\) is true, and the p-value is represented by the two shaded tails:
A bell-shaped distribution is shown, with a center of mu-sub-0, which has a value of 0. The area under the distribution above x-bar-sub-diff equals 3.58 is shaded, as is the corresponding tail below -3.58.
Figure 7.2.6.
The degrees of freedom is \(df = 68 - 1 = 67\text{.}\) Using statistical software, we find the one-tail area of 0.0156. Doubling this area gives the p-value: 0.0312.
Because the p-value is less than 0.05, we reject the null hypothesis. Amazon prices are, on average, lower than the UCLA Bookstore prices for UCLA courses.

Checkpoint 7.2.7.

Create a 95% confidence interval for the average price difference between books at the UCLA bookstore and books on Amazon.
โ€‰1โ€‰
Conditions have already been verified and the standard error computed in Exampleย 7.2.4. To find the interval, identify \(t^{\star}_{67}\) using statistical software or the \(t\)-table (\(t^{\star}_{67} = 2.00\)), and plug it, the point estimate, and the standard error into the confidence interval formula: \(\text{point estimate} \pm t^{\star} \times SE \to 3.58 \pm 2.00 \times 1.63 \to (0.32, 6.84)\text{.}\) We are 95% confident that Amazon is, on average, between $0.32 and $6.84 less expensive than the UCLA Bookstore for UCLA course books.

Checkpoint 7.2.8.

We have strong evidence that Amazon is, on average, less expensive. How should this conclusion affect UCLA student buying habits? Should UCLA students always buy their books on Amazon?
โ€‰2โ€‰
The average price difference is only mildly useful for this question. Examine the distribution shown in Figureย 7.2.2. There are certainly a handful of cases where Amazon prices are far below the UCLA Bookstoreโ€™s, which suggests it is worth checking Amazon (and probably other online sites) before purchasing. However, in many cases the Amazon price is above what the UCLA Bookstore charges, and most of the time the price isnโ€™t that different. Ultimately, if getting a book immediately from the bookstore is notably more convenient, e.g. to get started on reading or homework, itโ€™s likely a good idea to go with the UCLA Bookstore unless the price difference on a specific book happens to be quite large. For reference, this is a very different result from what we (the authors) had seen in a similar data set from 2010. At that time, Amazon prices were almost uniformly lower than those of the UCLA Bookstoreโ€™s and by a large margin, making the case to use Amazon over the UCLA Bookstore quite compelling at that time. Now we frequently check multiple websites to find the best price.

Exercises 7.2.3 Section Exercises

1. Air quality.

Air quality measurements were collected in a random sample of 25 country capitals in 2013, and then again in the same cities in 2014. We would like to use these data to compare average air quality between the two years. Should we use a paired or non-paired test? Explain your reasoning.

2. True / False: paired.

Determine if the following statements are true or false. If false, explain.
  1. In a paired analysis we first take the difference of each pair of observations, and then we do inference on these differences.
  2. Two data sets of different sizes cannot be analyzed as paired data.
  3. Consider two sets of data that are paired with each other. Each observation in one data set has a natural correspondence with exactly one observation from the other data set.
  4. Consider two sets of data that are paired with each other. Each observation in one data set is subtracted from the average of the other data setโ€™s observations.

3. Paired or not? Part I.

In each of the following scenarios, determine if the data are paired.
  1. Compare pre- (beginning of semester) and post-test (end of semester) scores of students.
  2. Assess gender-related salary gap by comparing salaries of randomly sampled men and women.
  3. Compare artery thicknesses at the beginning of a study and after 2 years of taking Vitamin E for the same group of patients.
  4. Assess effectiveness of a diet regimen by comparing the before and after weights of subjects.

4. Paired or not? Part II.

In each of the following scenarios, determine if the data are paired.
  1. We would like to know if Intelโ€™s stock and Southwest Airlinesโ€™ stock have similar rates of return. To find out, we take a random sample of 50 days, and record Intelโ€™s and Southwestโ€™s stock on those same days.
  2. We randomly sample 50 items from Target stores and note the price for each. Then we visit Walmart and collect the price for each of those same 50 items.
  3. A school board would like to determine whether there is a difference in average SAT scores for students at one high school versus another high school in the district. To check, they take a simple random sample of 100 students from each high school.

5. Global warming, Part I.

Letโ€™s consider a limited set of climate data, examining temperature differences in 1948 vs 2018. We sampled 197 locations from the National Oceanic and Atmospheric Administrationโ€™s (NOAA) historical data, where the data was available for both years of interest. We want to know: were there more days with temperatures exceeding 90ยฐF in 2018 or in 1948? The difference in number of days exceeding 90ยฐF (number of days in 2018 - number of days in 1948) was calculated for each of the 197 locations. The average of these differences was 2.9 days with a standard deviation of 17.2 days. We are interested in determining whether these data provide strong evidence that there were more days in 2018 that exceeded 90ยฐF from NOAAโ€™s weather stations.
A histogram is shown for "Differences in Number of Days", which has bins between -70 and 60, where the bin width is 10. There is a prominent peak around zero, where much of the data lies between -40 and positive 40. The non-zero bins beyond this range are -70 to -60 has a bin height of 1, the 40 to 50 bin has a bin height of 2, and the 50 to 60 bin has a bin height of 1.
Figure 7.2.9.
  1. Is there a relationship between the observations collected in 1948 and 2018? Or are the observations in the two groups independent? Explain.
  2. Write hypotheses for this research in symbols and in words.
  3. Check the conditions required to complete this test. A histogram of the differences is given to the right.
  4. Calculate the test statistic and find the p-value.
  5. Use \(\alpha = 0.05\) to evaluate the test, and interpret your conclusion in context.
  6. What type of error might we have made? Explain in context what the error means.
  7. Based on the results of this hypothesis test, would you expect a confidence interval for the average difference between the number of days exceeding 90ยฐF from 1948 and 2018 to include 0? Explain your reasoning.

6. High School and Beyond, Part I.

The National Center of Education Statistics conducted a survey of high school seniors, collecting test data on reading, writing, and several other subjects. Here we examine a simple random sample of 200 students from this survey. Side-by-side box plots of reading and writing scores as well as a histogram of the differences in scores are shown below.
Side-by-side box plot with dot plots also overlaid for each box plot. There are two categories shown, "read" and "write", for values ranging from about 27 to 77. The box portion of each distribution is nearly identical, ranging from about 45 to 60. The median of "read" is about 49 while the median of "write" is about 53. The whiskers for "read" extend down to about 27 and up to 77, while the whiskers for "write" extend down to about 32 and up to about 67. No points are shown beyond the whiskers for either box plot.
Figure 7.2.10.
A histogram is shown for "Difference in scores (read minus write)", which is centered at approximately zero and is roughly bell-shaped with values ranging from -25 to positive 25.
Figure 7.2.11.
  1. Is there a clear difference in the average reading and writing scores?
  2. Are the reading and writing scores of each student independent of each other?
  3. Create hypotheses appropriate for the following research question: is there an evident difference in the average scores of students in the reading and writing exam?
  4. Check the conditions required to complete this test.
  5. The average observed difference in scores is \(\bar{x}_{\text{read-write}} = -0.545\text{,}\) and the standard deviation of the differences is 8.887 points. Do these data provide convincing evidence of a difference between the average scores on the two exams?
  6. What type of error might we have made? Explain what the error means in the context of the application.
  7. Based on the results of this hypothesis test, would you expect a confidence interval for the average difference between the reading and writing scores to include 0? Explain your reasoning.

7. Global warming, Part II.

We considered the change in the number of days exceeding 90ยฐF from 1948 and 2018 at 197 randomly sampled locations from the NOAA database in Exerciseย 7.2.3.5. The mean and standard deviation of the reported differences are 2.9 days and 17.2 days.
  1. Calculate a 90% confidence interval for the average difference between number of days exceeding 90ยฐF between 1948 and 2018. Weโ€™ve already checked the conditions for you.
  2. Interpret the interval in context.
  3. Does the confidence interval provide convincing evidence that there were more days exceeding 90ยฐF in 2018 than in 1948 at NOAA stations? Explain.

8. High school and beyond, Part II.

We considered the differences between the reading and writing scores of a random sample of 200 students who took the High School and Beyond Survey in Exerciseย 7.2.3.6. The mean and standard deviation of the differences are \(\bar{x}_{\text{read-write}} = -0.545\) and 8.887 points.
  1. Calculate a 95% confidence interval for the average difference between the reading and writing scores of all students.
  2. Interpret this interval in context.
  3. Does the confidence interval provide convincing evidence that there is a real difference in the average scores? Explain.