Each textbook has two corresponding prices in the data set: one for the UCLA bookstore and one for Amazon. Therefore, each textbook price from the UCLA bookstore has a natural correspondence with a textbook price from 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 analyse paired data, it is often useful to look at the difference in outcomes of each pair of observations. In the textbook data set, we look at the difference in prices, which is represented as the diff variable in the textbooks data. Here the differences are taken as
for each book. It is important that we always subtract using a consistent order; here Amazon prices are always subtracted from UCLA prices. A histogram of these differences is shown in Figure LABEL:diffInTextbookPricesS10. Using differences between paired observations is a common and useful way to analyse paired data.
R> data(textbooks) R> hist(textbooks[,7], xlim=c(-20, 80))