Lecture notes · Introduction to Mathematical Statistics · Chapter 8

Chapter 8. Types of Data: A Brief Overview: Lecture Notes

Chapters 5 to 7 analysed one kind of data: a single random sample. Real data come in many shapes, and the shape, not the formula, decides which analysis is legitimate. This short chapter is a map. Five questions (quantitative or not, similar units or not, how many factors, how many levels, dependent or independent) sort almost every data set into one of eight designs; for each design the notes give the model equation, the question it answers, the book's case study and the chapter that analyses it. The mathematics is concentrated in a few places where the book states a claim without an argument: why a shared effect makes observations dependent, why pairing and blocking can shrink the variance of a comparison, why random assignment protects against bias, why the least-squares line does not care whether the predictor is chosen or observed, and why two of the flow chart's boxes overlap exactly.

Course home Ch. 1 Introduction Ch. 2 Probability Ch. 3 Random variables Ch. 4 Special distributions Ch. 5 Estimation Ch. 6 Hypothesis testing Ch. 7 Normal-based inference Ch. 8 Types of data Ch. 9 Two-sample inference Ch. 10 Goodness of fit Ch. 11 Regression Ch. 12 Analysis of variance Ch. 13 Randomized blocks Ch. 14 Nonparametric statistics

How to use the gap boxes and selected questions

Each Filling the gap box completes a step or a proof the book leaves out, and each selected question asks you to apply the chapter. Try it yourself first. When you are stuck, open Hint 1; the next hint unlocks one minute after you open the previous one, so take one hint at a time and think about it before moving on: the key idea first, then the tools, then the steps, with intermediate results to aim for. The full proof or solution appears after the last hint and unlocks two minutes later: use it to check your own argument. If you use a generative AI assistant, use it the same way: ask for a hint or for the next step only, then check what it says against these notes (why I teach this way). Spotted a mistake? Use the Report an error link at the end of each box: confirmed errors are corrected and listed, with thanks, in the errata.

How to read these notes

They follow the book. Sections carry the book's numbers (8.1 and 8.2) and numbered items keep theirs (Case Study 8.2.5, Example 8.2.1, Figure 8.2.3). Everything is written in new words; the book is cited for each case study, result and figure. The chapter has no theorems of its own, so the numbered items are case studies, examples and figures.

Filling the gaps. Where the book asserts something without proof (a design is "better", a procedure "makes no difference", two models "overlap"), an orange Filling the gap box gives the argument. Proofs start hidden: open one with its bar, or use the button below. Each gap box and each selected question offers graded hints, one at a time, before the full argument.

Figures and demonstrations. Three of the book's seven figures are reproduced (8.1.2, 8.2.2 and 8.2.3) and two figures of my own are added (x8.1 and x8.2). The other four are drawings (an empty table layout, a recording scheme, a random run order and two flow charts); the flow charts are replaced by a table and the five questions are also written as a short function in the code. The chapter's one quantitative idea that benefits from a demonstration, why pairing helps, is already covered by a first-year demonstration, which is linked where it applies instead of being rebuilt.

Main reference

R. J. Larsen and M. L. Marx, An Introduction to Mathematical Statistics and Its Applications, 6th edition, Pearson (2018), Chapter 8, pages 421–449. Section, case-study, figure and question numbers below refer to this book. Further reading is listed in the references.

The explanations, derivations, figures and code are my own; equations are cited by their numbers in the book.

Companion courses

Several designs of this chapter are treated in depth elsewhere on this site. Where a proof there is complete, these notes give the statement and a short argument and link to it.

New here: dependence from a shared effect (Filling the gap 8.1), the between and within sums of squares of a k-sample design (8.2), the variance saved by pairing and its price in degrees of freedom (8.3), blocks (8.4), randomization (8.5), chosen versus observed predictors (8.6), Hubble's constant in full (8.7), the two-by-two table (8.8), interaction (8.9) and the two overlaps of the flow chart (8.10).

The chapter at a glance

  • 8.1 A factor is a treatment or a characteristic of the subjects, its levels are its versions; a block is a shared background the experimenter does not care about but must handle. Observations are dependent if they share such a background (8.1), similar if they have the same units, quantitative if numerical. These words define eight designs.
  • 8.2 Five questions classify the data (table). Each design has a model equation, a typical inference and a place in later chapters (map below). Pairing and blocking compare treatments on the same subjects, which removes the subject-to-subject variation (8.3, 8.4); random order protects against bias (8.5); a regression line is the same whether \(x\) is chosen or observed (8.6); and two designs, paired and randomized block with two levels, and two-sample and k-sample with two levels, give the same test (8.10).
DesignModel equationTypical questionAnalysed in
One-sample\(Y_i=\mu+\varepsilon_i\)Is \(\mu=\mu_0\)? A confidence interval for \(\mu\) or \(\sigma\).Chapter 5 (estimation), Chapter 6 (tests), Chapter 7 (the normal law: \(t\), \(\chi^2\))
Two-sample\(X_i=\mu_X+\varepsilon_i,\ Y_j=\mu_Y+\varepsilon_j'\)Is \(\mu_X=\mu_Y\)? Is \(\sigma_X=\sigma_Y\)? Is \(p_X=p_Y\)?Chapter 9 (\(t\) test, \(F\) test, two proportions)
k-sample\(Y_{ij}=\mu_j+\varepsilon_{ij}\)Is \(\mu_1=\dots=\mu_k\)? Which pairs differ?Chapter 12 (one-way analysis of variance, multiple comparisons)
Paired\(X_i=\mu_X+P_i+\varepsilon_i,\ Y_i=\mu_Y+P_i+\varepsilon_i'\)Is \(\mu_D=\mu_X-\mu_Y=0\)?Chapter 13 (paired \(t\) test)
Randomized block\(Y_{ij}=\mu_j+B_i+\varepsilon_{ij}\)Is \(\mu_1=\dots=\mu_k\), blocks removed?Chapter 13 (\(F\) test for a randomized block design)
Regression / correlation\(Y_i=\beta_0+\beta_1x_i+\varepsilon_i\)The functional relation; is \(\beta_1=0\)? Is \(\rho=0\)?Chapter 11 (least squares, inference on the line and on \(\rho\))
Categoricalcounts \(n_{ij}\) in an \(R\times C\) tableAre the two classifications independent?Chapter 10 (chi-squared tests, contingency tables)
Factorial\(Y_{ijk}=\mu+\alpha_i+\beta_j+\gamma_{ij}+\varepsilon_{ijk}\)Which factors act? Do they interact?Chapter 15 of the book (not part of this course); see Filling the gap 8.9

Chapter 14 (nonparametric statistics) gives rank-based tests for the same designs when the normal model is doubtful. The chapters named in plain text are not yet part of this course; their links will be added when they exist.

Notation. \(\P\), \(\E\), \(\V\) are probability, mean and variance; \(\Cov\) is covariance and \(\Corr\) correlation. \(\N(\mu,\sigma^2)\) is the normal law. For a table \(Y_{ij}\), a dot replaces an index that is averaged over: \(\bar y_{i\cdot}\) is the mean of row \(i\), \(\bar y_{\cdot j}\) the mean of column \(j\) and \(\bar y\) the grand mean. The letters \(\varepsilon\) stand for independent errors with mean 0.

Prerequisites. Variance of a sum and covariance (Section 3.9, Theorem 3.9.5), the normal law (Section 4.3), unbiasedness and efficiency (Section 5.4) and the logic of a test (Chapter 6).

Derivations start hidden: click any bar to open one.

8.1 Introduction

pp. 421–422 Chapters 5 to 7 studied a sample \(Y_1,\dots,Y_n\) from one law. That is the "micro" structure of a data set: the law of each \(Y_i\), its mean and variance, whether the \(Y_i\) are independent. A second, "macro" structure sits above it: how the observations were gathered, which conditions they represent and which of them belong together. The macro structure, the experimental design, decides which comparisons the data can answer and which formulas are valid. This chapter names the pieces of a design and sorts the common designs into eight families; the analysis of each family is the subject of the following chapters.

Factors and levels

p. 422 A factor is a treatment applied to the subjects or a characteristic of them (a drug, a sex, an age group); its levels are its different versions or amounts.

Case Study 8.1.1: smoking and heart rate p. 422

Six nonsmokers, six light smokers, six moderate smokers and six heavy smokers exercised, and their heart rates were recorded after three minutes of rest. Data: Case Study 8.1.1 (Table 8.1.1).

NonsmokersLightModerateHeavy
Heart rates69, 52, 71, 58, 59, 6555, 60, 78, 58, 62, 6666, 81, 70, 77, 57, 7991, 72, 81, 67, 95, 84
Average62.363.271.781.7

There is one factor, smoking, with four levels. A richer study could add the factors sex (two levels) and age (three levels), giving \(4\times2\times3=24\) combinations of levels (Figure 8.1.1 in the book is the empty table for them). The 24 people are all different people, so these are four independent samples: a k-sample design with \(k=4\).

Blocks

p. 423 Subjects or environments often share a characteristic that changes how every level of the factor responds, though the experimenter has no interest in it. Such a set of shared conditions is a block.

Case Study 8.1.2: rat-poison flavours p. 423

Four flavours of bait (plain, butter-vanilla, roast beef, bread) were compared in a rodent-control trial in Milwaukee. In each of five two-week surveys, 800 baits of each flavour were put out at a new set of locations and the percentage taken was recorded. Data: Case Study 8.1.2 (Table 8.1.2).

SurveyPlainButter-vanillaRoast beefBread
113.811.714.012.6
212.916.715.513.8
325.929.827.825.0
418.023.123.016.9
515.220.219.013.7

The weather, the sites and the food available differ from survey to survey (survey 3 has far higher percentages in every column), but the aim is only to compare flavours. The five surveys are blocks: five shared backgrounds, each carrying one measurement of every flavour. Figure x8.1 (left) shows it: the lines of the five blocks are parallel-ish and far apart, and what the experimenter wants, the differences between flavours, is small by comparison with the differences between blocks.

Two panels of line plots. Left: the bait-acceptance percentage of each of five surveys across the four flavours, five roughly parallel lines at very different heights from about 12 to 30 percent with a thick line for the flavour means. Right: the ten thousand metre time of each of six runners across the three conditions no injection, placebo and blood doping, six lines that overlap and cross, with a thick line of means decreasing from 33.5 to 32.3 minutes.
Figure x8.1. Each block is one line across the factor levels. In Table 8.1.2 (left) the block lines sit at very different heights and are nearly parallel: the block effect is large and removing it makes the flavour differences visible. In Table 8.2.5 (right) the runners differ less from one another and the lines cross more. Own figure. Code: ch08_types_of_data.py, fig_x8_1.

Independent and dependent observations

p. 424 Measurements made to compare factor levels are dependent if they share a commonality that affects what is measured, and independent otherwise. In Table 8.1.2 the 13.8 (plain, survey 1) and the 11.7 (butter-vanilla, survey 1) share the conditions of survey 1, so they are dependent; in Table 8.1.1 the first two entries of the first column, 69 and 52, merely share a factor level and are independent. Twins, littermates, repeated measurements on one subject, plots of one field, readings from one instrument or one operator, and a common time or place are the standard ways to create dependence on purpose. Section 8.2 and Chapters 13 and 14 will show that comparing levels on dependent observations is often much more efficient. The next box says exactly where the dependence comes from and how large it is.

Filling the gap 8.1: a shared effect makes observations dependent, and different blocks are independent p. 424

The book defines dependence by "sharing a commonality" and later writes a block effect \(B_i\) into its model equation. A definition in words is not yet a statement about probabilities. Take the block model of Section 8.2, \(Y_{ij}=\mu_j+B_i+\varepsilon_{ij}\), with the block effects \(B_i\) independent with mean 0 and variance \(\sigma_B^2\), the errors \(\varepsilon_{ij}\) independent with mean 0 and variance \(\sigma^2\), and the \(B_i\) independent of the \(\varepsilon_{ij}\). Then two observations in the same block have covariance \(\sigma_B^2\) and correlation \(\sigma_B^2/(\sigma_B^2+\sigma^2)\); two observations in different blocks, or two at the same level in different blocks, are independent.

Hint 1 of 4: the key idea

Dependence has to come from something the two observations literally have in common. What random quantity appears in both \(Y_{ij}\) and \(Y_{il}\), and what happens to a covariance when two sums share one term?

Hint 2 of 4: tools you will need
  • Bilinearity of covariance: \(\Cov(A+B,C+D)\) expands into four terms (Theorem 3.9.5).
  • Independent variables have zero covariance.
  • Functions of disjoint sets of independent variables are independent (gap 3.14).
Hint 3 of 4: step 1

Expand \(\Cov(B_i+\varepsilon_{ij},B_i+\varepsilon_{il})\) for \(j\ne l\) and say which of the four terms survive. Aim for: \(\sigma_B^2\).

Hint 4 of 4: step 2

Do the same for \(j=l\) to get the variance, then form the correlation. Aim for: \(\sigma_B^2/(\sigma_B^2+\sigma^2)\). For different blocks, which variables does each observation depend on?

Proof

Take \(j\ne l\). The constants \(\mu_j,\mu_l\) do not affect covariances, and covariance is additive in each argument, so \[\Cov(Y_{ij},Y_{il})=\Cov(B_i+\varepsilon_{ij},\,B_i+\varepsilon_{il})=\V B_i+\Cov(B_i,\varepsilon_{il})+\Cov(\varepsilon_{ij},B_i)+\Cov(\varepsilon_{ij},\varepsilon_{il})=\sigma_B^2,\] because the \(B_i\) and the \(\varepsilon\)'s are independent of one another. Each observation has variance \(\V Y_{ij}=\sigma_B^2+\sigma^2\), by the same expansion with \(j=l\). The correlation is the covariance divided by the common standard deviation squared, \(\sigma_B^2/(\sigma_B^2+\sigma^2)\), which lies in \([0,1)\) and tends to 1 as the block effect swamps the noise.

For \(i\ne i'\), \(Y_{ij}\) is a function of \((B_i,\varepsilon_{ij})\) and \(Y_{i'l}\) a function of \((B_{i'},\varepsilon_{i'l})\), two disjoint groups of independent variables, so \(Y_{ij}\) and \(Y_{i'l}\) are independent (functions of independent variables are independent, gap 3.14), whether or not \(j=l\). In particular sharing a factor level creates no dependence, as the book says of 69 and 52.

Illustration. The four columns of Table 8.1.2 are the four levels; the average of their six pairwise sample correlations is 0.94, close to the maximum, reflecting a block effect that is far larger than the noise. By contrast the four columns of Table 8.1.1 hold different people and show no such structure. ∎

Similar and dissimilar units

p. 424 Two measurements are similar if their units are the same. Comparing the effects of levels of a factor is the typical aim when all units are similar (Case Studies 8.1.1 and 8.1.2). Dissimilar units call for describing a relationship between the variables.

Case Study 8.1.3: the American ICBM arsenal, 1960 to 1969 pp. 424–425

The number of intercontinental ballistic missiles was 18, 63, 294, 424, 834, 854, 904 and then 1054 in each of the last three years. The variables are the year and the count: different units, and the aim is to describe how one grows with the other. The S-shaped curve of Figure 8.1.2 is a logistic curve \(y=K/(1+e^{-(x-x_0)/s})\), a model of growth that levels off at a ceiling \(K\). Data: Case Study 8.1.3.

Ten dots rising in an S shape from 18 in year 1 to 1054 in years 8 to 10, with a dashed logistic curve through them that levels off near 1036.
Figure 8.1.2. The size of the ICBM stockpile against years after 1959. The book does not print the equation of its dashed curve; the curve drawn here is a least-squares logistic fit of my own, with ceiling \(K=1036\), midpoint 4.12 years after 1959 and scale 0.96. Reproduces Larsen and Marx (2018), Figure 8.1.2. Code: ch08_types_of_data.py, fig_8_1_2.

Quantitative and qualitative measurements

pp. 425–426 A measurement is quantitative if its possible values are numbers (heart rates, percentages) and qualitative if its values are categories.

Case Study 8.1.4: two kinds of stalkers pp. 425–426

Thirty-four people jailed in New York for violating restraining orders were classified as amorous stalkers (14) or judicial stalkers (20, those who target judges). One of the facts recorded was whether the person had a white-collar job. Data: Case Study 8.1.4 (Table 8.1.3).

White-collar jobOtherTotal% white-collar
Amorous4101429%
Judicial10102050%

The entries are numbers, but they are counts of people, a numerical summary of two qualitative variables: type of stalker (amorous or judicial) and white-collar job (yes or no). These are categorical data. The two variables are recorded on each of the 34 people.

The eight designs

p. 426 The definitions allow many designs, but a short list covers most data: one-sample, two-sample, k-sample, paired, randomized block, regression and correlation, categorical and factorial data. Table 8.1.1 is k-sample, Table 8.1.2 randomized block, Figure 8.1.2 regression and Table 8.1.3 categorical.

8.2 Classifying Data

p. 427 Five questions place a data set among the eight designs. They are the starting point of every analysis, because the design dictates the analysis.

QuestionAnswerConsequence
1. Quantitative or qualitative?qualitativecategorical data
2. Similar or dissimilar units?dissimilarregression or correlation data
3. One factor or more than one?two or morefactorial data
4. How many factor levels?oneone-sample data
twopaired data if dependent, two-sample data if independent
three or morerandomized block data if dependent, k-sample data if independent
5. Dependent or independent samples?(used in the last two rows of question 4)

The questions are asked in this order (the book's flow chart, Figure 8.2.4, is this table drawn as a tree; the code function classify implements it). The next subsections describe each design with its model equation, the book's case study and the inference it is made for.

One-sample data

p. 427 The simplest design is one random sample of size \(n\) under one set of conditions. The conditions often suggest the law: the 423 observations of Case Study 4.2.3 are Poisson counts, and by Theorem 4.2.3 the 218 gaps between 219 New Madrid earthquakes of Case Study 4.2.4 form a sample from an exponential law (Section 4.2). Most often the model is normal with unknown mean and standard deviation, \[ Y_i=\mu+\varepsilon_i,\qquad \varepsilon_i\sim\N(0,\sigma^2)\ \text{independent},\quad i=1,\dots,n, \] a model equation: the value of any \(Y_i\) is a fixed part plus a random part. Inference is a test or a confidence interval for \(\mu\) or \(\sigma\), covered by Chapter 5 and Chapter 6 and, for the normal law, Chapter 7.

Case Study 8.2.1: how long inventions take to reach the shelf pp. 427–428

Seventeen familiar products are listed with the year of conception and the year they appeared in the shops, and \(y\) is the difference (Minute Rice: 1931 to 1949, \(y=18\)); the average of the seventeen development times is 22.2 years. This is one-sample data, but the book rightly cautions that such "fun lists" are not a random sample of all inventions, so a formal inference about the true mean would be unjustified. A design is only as good as the sampling behind it: the first condition of every model in this chapter is that the observations were collected the way the model says.

Two-sample data

pp. 428–430 Two-sample data are two independent random samples of sizes \(n\) and \(m\), quantitative with similar units, each sample at one level of a factor. If the observations are Bernoulli trials (0 or 1) the parameters are two success probabilities and the usual test is \(H_0\colon p_X=p_Y\). Far more often the two samples are normal: \[ X_i=\mu_X+\varepsilon_i,\ \varepsilon_i\sim\N(0,\sigma_X^2),\ i=1,\dots,n;\qquad Y_j=\mu_Y+\varepsilon_j',\ \varepsilon_j'\sim\N(0,\sigma_Y^2),\ j=1,\dots,m. \] The inference is usually a test of \(H_0\colon\mu_X=\mu_Y\) (a two-sample \(t\) test) or of \(H_0\colon\sigma_X=\sigma_Y\) (an \(F\) test), both in Chapter 9. A one-sample test of \(H_0\colon\mu=\mu_0\) silently assumes that the data were taken under the same conditions as the standard value \(\mu_0\); the two-sample design lets the experimenter control the conditions of both samples.

Case Study 8.2.2: sunspots and hurricanes pp. 429–430

The Zurich number measures sunspot activity: \[R_Z=10\cdot(\text{sunspot groups})+(\text{individual sunspots}).\] Among the years on record, the ten with the highest \(R_Z\) (high activity) and the ten with the lowest (low activity) had the following numbers of North Atlantic hurricanes. Data: Case Study 8.2.2 (Table 8.2.2).

High sunspot years, \(X\)5, 4, 3, 7, 7, 5, 9, 7, 8, 4mean 5.9
Low sunspot years, \(Y\)5, 5, 3, 3, 3, 4, 3, 3, 10, 8mean 4.7

The factor is sunspot activity with levels high and low. The sample means differ by 1.2, and the sample standard deviations are 1.97 and 2.45, so the standard error of \(\bar x-\bar y\) is \(\sqrt{1.97^2/10+2.45^2/10}=0.99\): the difference is about 1.2 standard errors. Whether that is significant is the job of the two-sample \(t\) test of Chapter 9. The raw numbers also overlap strongly: two of the highest hurricane years had two of the lowest sunspot numbers, so sunspots are at most one of several influences on hurricanes.

k-sample data

p. 430 With more than two levels, quantitative similar-unit observations and independent samples we have k-sample data. The two-sample \(t\) test does not extend to it; the tool is the analysis of variance (Chapter 12). Observations carry two subscripts, \(Y_{ij}\) for the \(i\)-th observation at the \(j\)-th level: \[ Y_{ij}=\mu_j+\varepsilon_{ij},\qquad i=1,\dots,n_j,\ j=1,\dots,k,\qquad n_1+\dots+n_k=n,\quad\varepsilon_{ij}\sim\N(0,\sigma^2)\ \text{independent}. \] The first inference is \(H_0\colon\mu_1=\dots=\mu_k\); further procedures compare chosen levels.

Case Study 8.2.3: the magnetic field and Mount Etna pp. 431–432

Lava cools with its iron and nickel particles pointing along the magnetic field of the day. Three blocks of lava from each of three eruptions of Mount Etna give the magnetic declination (the angle between true north and magnetic north). Data: Case Study 8.2.3 (Table 8.2.3).

166917801865
Declinations57.8, 60.2, 60.357.9, 55.2, 54.852.7, 53.0, 49.4
Average59.456.051.7

The question is whether the three averages differ by more than the scatter within each group would produce; the answer is the \(F\) ratio of between-group to within-group variation (Filling the gap 8.2). The three eruption years were not chosen by the experimenter, so "time" is a random effect; a factor whose levels the experimenter picks is a fixed effect. The distinction does not change the analysis of the first seven designs, but it does for factorial data.

Filling the gap 8.2: why "between relative to within" is the right comparison for \(k\) means pp. 430–431

The book says the \(k\) averages should be compared with the variation inside the groups and names the \(F\) distribution as the tool, without showing why that ratio detects unequal means. Take the k-sample model with independent errors of mean 0 and variance \(\sigma^2\) (normality is not needed yet). Let \(\bar y_j\) be the mean of level \(j\), \(\bar y\) the grand mean, and define \[ \mathrm{SSB}=\sum_{j=1}^k n_j(\bar y_j-\bar y)^2,\qquad \mathrm{SSW}=\sum_{j=1}^k\sum_{i=1}^{n_j}(y_{ij}-\bar y_j)^2,\qquad \mathrm{SST}=\sum_{j,i}(y_{ij}-\bar y)^2 . \] Then (a) \(\mathrm{SST}=\mathrm{SSB}+\mathrm{SSW}\); (b) \(\E\,\mathrm{SSW}=(n-k)\sigma^2\); (c) \(\E\,\mathrm{SSB}=(k-1)\sigma^2+\sum_j n_j(\mu_j-\bar\mu)^2\), with \(\bar\mu=\sum_j n_j\mu_j/n\). Hence \(\mathrm{SSW}/(n-k)\) always estimates \(\sigma^2\), while \(\mathrm{SSB}/(k-1)\) estimates \(\sigma^2\) only if all means are equal and is larger on average otherwise.

Hint 1 of 5: the key idea

Split each deviation \(y_{ij}-\bar y\) into a part inside the group and a part between group means. What does a deviation from a group's own mean add up to, and what does that do to the cross term?

Hint 2 of 5: tools you will need
  • \(\E Z^2=\V Z+(\E Z)^2\).
  • Variance of a sample mean and of a linear combination of independent means (Theorem 3.9.5).
  • The sample variance is unbiased (Example 5.4.4).
Hint 3 of 5: part (a)

Add and subtract \(\bar y_j\), square, and sum. Aim for: the cross term is \(2\sum_j(\bar y_j-\bar y)\sum_i(y_{ij}-\bar y_j)=0\).

Hint 4 of 5: part (b)

Take the expectation inside each group separately. Aim for: \((n_j-1)\sigma^2\) per group, so \((n-k)\sigma^2\) in total.

Hint 5 of 5: part (c)

For each \(j\) find the mean and the variance of \(\bar y_j-\bar y\). You need \(\Cov(\bar y_j,\bar y)\): write \(\bar y\) as a weighted average of the group means. Aim for: variance \(\sigma^2(1/n_j-1/n)\); then multiply by \(n_j\) and sum.

Proof

(a) Write \(y_{ij}-\bar y=(y_{ij}-\bar y_j)+(\bar y_j-\bar y)\) and square. The cross term is \(2\sum_j(\bar y_j-\bar y)\sum_i(y_{ij}-\bar y_j)=0\), because deviations from a group's own mean sum to 0.

(b) Within level \(j\) the \(y_{ij}\) are \(n_j\) independent variables with variance \(\sigma^2\), and \(\E\sum_i(y_{ij}-\bar y_j)^2=(n_j-1)\sigma^2\) (the sample variance is unbiased, Example 5.4.4). Sum over \(j\): \((n-k)\sigma^2\).

(c) For any random variable \(Z\), \(\E Z^2=\V Z+(\E Z)^2\). Here \(\E\bar y_j=\mu_j\), \(\E\bar y=\bar\mu\), so \(\E(\bar y_j-\bar y)=\mu_j-\bar\mu\). For the variance, \(\V\bar y_j=\sigma^2/n_j\), \(\V\bar y=\sigma^2/n\), and, since \(\bar y=\sum_l n_l\bar y_l/n\) with independent group means, \(\Cov(\bar y_j,\bar y)=\tfrac{n_j}{n}\cdot\tfrac{\sigma^2}{n_j}=\sigma^2/n\). Therefore \[\V(\bar y_j-\bar y)=\frac{\sigma^2}{n_j}-2\frac{\sigma^2}{n}+\frac{\sigma^2}{n}=\sigma^2\Bigl(\frac1{n_j}-\frac1n\Bigr).\] Multiplying by \(n_j\) and summing over \(j\) gives \(\sigma^2(k-1)\) for the variance part, plus \(\sum_jn_j(\mu_j-\bar\mu)^2\) from the squared means. ∎

Illustration (Case Study 8.2.3). The three groups of three have \(\mathrm{SSB}=90.03\) and \(\mathrm{SSW}=17.67\); the mean squares are \(90.03/2=45.01\) and \(17.67/6=2.95\), a ratio of 15.3. If the three means were equal both mean squares would estimate the same \(\sigma^2\) and the ratio would be near 1. Chapter 12 turns the size of such a ratio into a P-value; the \(F\) law is the law of a ratio of independent scaled chi-squared variables (Chapter 4 and the book's Section 7.3). For Case Study 8.1.1 the ratio is 6.1.

Paired data

pp. 432–433 Two-sample and k-sample designs compare levels on independent samples. A dependent alternative groups subjects into \(n\) blocks, called pairs when there are two levels. Let \(X_i\) and \(Y_i\) be the responses to the two levels in pair \(i\), and \(P_i\) the contribution of the conditions of pair \(i\), common to both. The model equations are \[ X_i=\mu_X+P_i+\varepsilon_i,\qquad Y_i=\mu_Y+P_i+\varepsilon_i',\qquad i=1,\dots,n,\] with independent normal errors of standard deviations \(\sigma\) and \(\sigma'\). The shared \(P_i\) makes \(X_i\) and \(Y_i\) dependent (Filling the gap 8.1). The aim is usually the same as for two samples, \(H_0\colon\mu_X=\mu_Y\), but the analysis defines \(\mu_D=\mu_X-\mu_Y\) and tests \(H_0\colon\mu_D=0\): the paired \(t\) test is the one-sample \(t\) test applied to the within-pair differences \(d_i=x_i-y_i\) (Chapter 13).

Case Study 8.2.4: does aspirin change blood-clotting time? pp. 432–433

Blood clots through a chain of reactions ending with fibrinogen turned into fibrin; the prothrombin time is the delay before the clot forms. Warfarin lengthens it and vitamin K shortens it. Twelve men had their prothrombin times measured before, and three hours after, taking two aspirin tablets (650 mg). Data: Case Study 8.2.4 (Table 8.2.4).

SubjectBefore, \(x_i\)After, \(y_i\)\(d_i=x_i-y_i\)
112.312.00.3
212.012.3-0.3
312.012.5-0.5
413.012.01.0
513.013.00
612.512.50
711.310.31.0
811.811.30.5
911.511.50
1011.011.5-0.5
1111.011.00
1211.311.5-0.2
Average11.8911.780.108

The mean difference is \(\bar d=0.108\) s, and the hypotheses are \(H_0\colon\mu_D=0\) against \(H_1\colon\mu_D\ne0\). The two-sample alternative would measure one group before and a different group after. Which design is better depends on the size of the pair effect \(P_i\) relative to the errors, the subject of the next box. (A caution of the design itself: every subject is measured "before" first and "after" second, so any drift over the three hours is confounded with aspirin; see Filling the gap 8.5.)

Filling the gap 8.3: why pairing shrinks the variance of the comparison, and what it costs p. 433

The book says the paired and two-sample formats are both possible, that the choice depends on "the amount of variability in the \(P_i\)'s relative to the \(\varepsilon_i\)'s", and that a small ratio favours the two-sample format. Work in the paired model above with \(\sigma_P^2=\V P_i\), the \(P_i\) and errors independent. (a) The paired estimator \(\bar D=\bar X-\bar Y\) has variance \((\sigma^2+\sigma'^2)/n\), free of \(\sigma_P^2\). (b) If the same \(2n\) observations were instead taken on \(2n\) different subjects, \(\V(\bar X-\bar Y)=(\sigma^2+\sigma'^2)/n+2\sigma_P^2/n\). (c) Pairing costs degrees of freedom, \(n-1\) against \(2n-2\); with \(\sigma=\sigma'\) the paired interval is shorter (comparing expected variance estimates) exactly when \[ \frac{\sigma_P^2}{\sigma^2}>\Bigl(\frac{t_{.025,\,n-1}}{t_{.025,\,2n-2}}\Bigr)^{2}-1, \] a threshold that is 0.126 for \(n=12\), 0.044 for \(n=30\) and tends to 0 as \(n\to\infty\).

Hint 1 of 5: the key idea

In the difference \(X_i-Y_i\) one thing appears with a plus sign and a minus sign. Which term of the model is it, and what does it do to the variance of the paired mean difference compared with two independent groups?

Hint 2 of 5: tools you will need
  • The paired model \(X_i=\mu_X+P_i+\varepsilon_i\), \(Y_i=\mu_Y+P_i+\varepsilon_i'\) and gap 8.1.
  • Variance of a difference and of a sample mean of independent variables (Theorem 3.9.5).
  • The paired and pooled interval lengths (Theorem 8.2 of the first-year notes).
Hint 3 of 5: step 1

Write \(D_i\) and find \(\V\bar D\). Aim for: \((\sigma^2+\sigma'^2)/n\) with no \(\sigma_P^2\).

Hint 4 of 5: step 2

For \(2n\) different subjects each observation carries its own \(P\). Find \(\V(\bar X-\bar Y)\). Aim for: the paired variance plus \(2\sigma_P^2/n\).

Hint 5 of 5: step 3

The two analyses use \(t\) quantiles with \(n-1\) and \(2n-2\) degrees of freedom. Set the expected half-lengths in order and take \(\sigma=\sigma'\). Aim for: \(\sigma_P^2/\sigma^2>(t_{n-1}/t_{2n-2})^2-1\). Does this threshold grow or shrink with \(n\)?

Proof

(a) The difference is \(D_i=X_i-Y_i=\mu_D+\varepsilon_i-\varepsilon_i'\): the \(P_i\) cancels. The \(D_i\) are independent across pairs with variance \(\sigma^2+\sigma'^2\), so \(\V\bar D=(\sigma^2+\sigma'^2)/n\). Equivalently \(\V(X_i-Y_i)=\V X_i+\V Y_i-2\Cov(X_i,Y_i)\) with \(\Cov(X_i,Y_i)=\sigma_P^2\) (gap 8.1); the pair effect appears in both variances and is subtracted off once for each, which is the first-year formula (Theorem 8.2) with \(\rho\sigma_X\sigma_Y=\sigma_P^2\). It also shows that pairing hurts if the covariance were negative.

(b) With different subjects, each \(X_i=\mu_X+P_i+\varepsilon_i\) has its own independent \(P_i\), and so does each \(Y_j\). All \(2n\) observations are independent, so \(\V\bar X=(\sigma_P^2+\sigma^2)/n\), \(\V\bar Y=(\sigma_P^2+\sigma'^2)/n\), and the variance of the difference is the sum, which exceeds (a) by \(2\sigma_P^2/n\).

(c) A 95% interval for \(\mu_D\) has half-length \(t_{.025,\nu}\) times the standard error, with \(\nu=n-1\) for the paired analysis (one-sample \(t\) on the \(n\) differences) and \(\nu=2n-2\) for the two-sample. Replacing each estimated variance by its expectation (a heuristic that compares typical lengths, since the expected length also involves the expected square root), the paired half-length is smaller iff \(t_{n-1}^2(\sigma^2+\sigma'^2)<t_{2n-2}^2(\sigma^2+\sigma'^2+2\sigma_P^2)\). With \(\sigma=\sigma'\), divide by \(2\sigma^2t_{2n-2}^2\): \((t_{n-1}/t_{2n-2})^2<1+\sigma_P^2/\sigma^2\), which is the claim. For \(n=12\): \(t_{.025,11}=2.201\) and \(t_{.025,22}=2.074\), ratio squared \(1.126\). The ratio tends to 1 as \(n\) grows because \(t_\nu\to z\). This is a comparison of expected lengths, a good guide though not an exact statement about power (Figure x8.2 compares power).

Illustration (Case Study 8.2.4). The sample variances of the before and after times are 0.497 and 0.560 and their sample covariance is 0.400 (correlation 0.76). The variance of the twelve differences is \(0.497+0.560-2(0.400)=0.257\), whereas independent samples with the same variances would give \(0.497+0.560=1.057\), four times as large. The standard errors are \(\sqrt{0.257/12}=0.146\) and \(\sqrt{1.057/12}=0.297\), and the statistic is \(0.108/0.146=0.74\) for the paired \(t\) test against \(0.108/0.297=0.37\) if the pairing were ignored. Neither test rejects \(H_0\), but the paired analysis is twice as precise. ∎

The power of the two-sample t test falls from about 0.65 to about 0.22 as the shared pair effect grows from 0 to 3 noise variances; the power of the paired t test is a flat line at 0.61; the curves cross near 0.10.
Figure x8.2. Power of the paired and of the two-sample \(t\) test for \(n=12\) subjects per group when the true difference equals the noise standard deviation \(\sigma\), against the size of the shared pair effect \(\sigma_P^2/\sigma^2\). The paired power is flat because \(P_i\) cancels from the differences; the two-sample power falls as the unpaired subjects bring in their own \(P_i\). The curves cross at 0.10: with almost no pair effect the extra degrees of freedom of the two-sample test give it a slight edge. Own figure. Code: ch08_types_of_data.py, fig_x8_2.
▶ DemoTwo samples: paired or not?First-year demo (preset 5): with correlation 0.85 between the two measurements on a person and 8 people the paired test has far more power than the same test ignoring the pairing. Preset 6 sets the correlation to 0: pairing gains nothing.

Randomized block data

pp. 433–435 A randomized block design is a paired design with \(k>2\) levels: quantitative, similar units, dependent samples. The paired \(t\) test cannot handle more levels; as in the k-sample design the analysis of variance is used (Chapter 13). With \(k\) levels each applied in each of \(b\) blocks, the model equation is \[ Y_{ij}=\mu_j+B_i+\varepsilon_{ij},\qquad i=1,\dots,b,\ j=1,\dots,k,\] where \(\mu_j\) is the true mean at level \(j\), \(B_i\) is the net effect of the conditions of block \(i\) and the errors are independent \(\N(0,\sigma^2)\). The first priority is \(H_0\colon\mu_1=\dots=\mu_k\).

Case Study 8.2.5: blood doping and ten-thousand-metre times p. 434

Blood doping raises the oxygen-carrying capacity of the blood, by transfusion of red cells or by injections of erythropoietin (EPO). Six runners each ran 10 000 m three times: after a transfusion of extra red cells, after a placebo injection, and after no treatment. Times in minutes. Data: Case Study 8.2.5 (Table 8.2.5).

SubjectNo injectionPlaceboBlood doping
134.0334.5333.03
232.8532.7031.55
333.5033.6232.33
432.5231.2331.20
534.1532.8532.80
633.7733.0533.07

The three times in a row are dependent: all reflect how fast that runner is. The runner differences are not of interest; the treatment differences are, and the test is \(H_0\colon\mu_1=\mu_2=\mu_3\). Column means: 33.47, 33.00 and 32.33 minutes (Figure x8.1, right).

Filling the gap 8.4: blocking removes the block effect from every comparison of levels pp. 433–434

The book describes the block term \(B_i\) and says that comparing levels on dependent observations is much more efficient, but never says why. In the block model, any comparison of two levels \(\bar y_{\cdot j}-\bar y_{\cdot l}\) has expected value \(\mu_j-\mu_l\) and variance \(2\sigma^2/b\), whatever the block effects \(B_i\) (they may be arbitrary constants). If instead each of the \(bk\) observations were made on its own unit with its own block-like effect (a completely randomized design), the variance would be \(2(\sigma_B^2+\sigma^2)/b\). Moreover the total variation splits exactly, \[ \sum_{i,j}(y_{ij}-\bar y)^2=k\sum_i(\bar y_{i\cdot}-\bar y)^2+b\sum_j(\bar y_{\cdot j}-\bar y)^2+\sum_{i,j}r_{ij}^2,\qquad r_{ij}=y_{ij}-\bar y_{i\cdot}-\bar y_{\cdot j}+\bar y, \] into block, level and error sums of squares.

Hint 1 of 4: the key idea

The block effect belongs to the row, not to the level. When you subtract two column means, what happens to something that is the same in every column?

Hint 2 of 4: tools you will need
  • The model \(Y_{ij}=\mu_j+B_i+\varepsilon_{ij}\).
  • Variance of a difference of independent means (Theorem 3.9.5).
  • Row sums and column sums of deviations from means are zero.
Hint 3 of 4: step 1

Write \(\bar y_{\cdot j}-\bar y_{\cdot l}\) and cancel. Aim for: a mean of \(\mu_j-\mu_l\) and a variance of \(2\sigma^2/b\) with no \(B_i\). What is the variance when every observation has its own unit effect?

Hint 4 of 4: step 2

For the identity, split \(y_{ij}-\bar y\) into a row part, a column part and \(r_{ij}\). Aim for: three squared terms, with all cross terms zero because \(\sum_jr_{ij}=0\) and \(\sum_ir_{ij}=0\).

Proof

The mean of column \(j\) is \(\bar y_{\cdot j}=\mu_j+\bar B+\bar\varepsilon_{\cdot j}\), with \(\bar B=\frac1b\sum_iB_i\) the same for every column. In the difference, \(\bar y_{\cdot j}-\bar y_{\cdot l}=\mu_j-\mu_l+\bar\varepsilon_{\cdot j}-\bar\varepsilon_{\cdot l}\): the block effects cancel exactly, for any values of the \(B_i\). The two error means are independent with variance \(\sigma^2/b\) each, so the variance is \(2\sigma^2/b\) and the mean \(\mu_j-\mu_l\). With a separate unit for each observation, \(Y_{ij}=\mu_j+U_{ij}+\varepsilon_{ij}\) with independent \(U_{ij}\) of variance \(\sigma_B^2\), the same computation gives \(2(\sigma_B^2+\sigma^2)/b\); the saving is \(2\sigma_B^2/b\), the same quantity as for pairs (gap 8.3, \(k=2\)).

For the identity, write \(y_{ij}-\bar y=(\bar y_{i\cdot}-\bar y)+(\bar y_{\cdot j}-\bar y)+r_{ij}\) (the three parts add to \(y_{ij}-\bar y\) by the definition of \(r_{ij}\)). Square and sum. The cross terms vanish: \(\sum_i(\bar y_{i\cdot}-\bar y)=0\) and \(\sum_j(\bar y_{\cdot j}-\bar y)=0\) make the product of the first two parts sum to \((\sum_i(\bar y_{i\cdot}-\bar y))(\sum_j(\bar y_{\cdot j}-\bar y))=0\), and \(\sum_jr_{ij}=0\) for every \(i\), \(\sum_ir_{ij}=0\) for every \(j\), so each part multiplies \(r_{ij}\) into a vanishing sum. ∎

Illustration. For Table 8.1.2 the total sum of squares is 581.5, of which 495.3 (85%) is due to the five surveys, 56.4 to the four flavours and 29.8 is error (12 degrees of freedom). The ratio of mean squares for flavours is \((56.4/3)/(29.8/12)=7.6\). If the surveys were ignored, as for four independent samples, the "error" would absorb the block variation, \(525.1\) on 16 degrees of freedom, and the ratio would fall to 0.57: the flavour effect would be invisible. For Table 8.2.5 the same two ratios are 10.3 and 2.6. ∎

pp. 434–435 Randomization. The name randomized block comes from the requirement that, in each block, the levels be applied in a random order; two-sample and k-sample data should be completely randomized, that is the whole set of measurements taken in a random order. The book's Figure 8.2.1 is an example of an acceptable run order (a drawing, not reproduced). The book's reason, that a systematic order gives "the opportunity for the observations to become biased", can be made precise.

Filling the gap 8.5: random assignment makes the comparison unbiased, a systematic order need not pp. 434–435

Take \(N=2m\) experimental units with fixed (unknown) responses \(a_1,\dots,a_N\) under level 1, and suppose level 2 adds an effect \(\tau\) to each unit. Assign \(m\) units to level 2 at random, each of the \(\binom Nm\) subsets being equally likely, and let \(D\) be the mean of the level-2 group minus the mean of the level-1 group. Then \(\E D=\tau\) whatever the \(a_i\). A systematic assignment, for instance level 2 on the last \(m\) units, has \(D-\tau\) equal to the difference of the group means of the \(a_i\), which a time trend turns into a bias that no sample size removes.

Hint 1 of 4: the key idea

Write the estimated difference as \(\tau\) plus a sum of the units' own responses weighted by \(\pm1\). If each unit is equally likely to be in either group, what is the expected sign of each weight?

Hint 2 of 4: tools you will need
  • Indicator variables \(Z_i\) and linearity of expectation.
  • Symmetry: each unit lies in a random subset of size \(m\) of \(N=2m\) with probability \(m/N\).
  • The mean of the \(a_i\) in a group when the group is fixed in advance.
Hint 3 of 4: step 1

Write \(D\) with the indicators \(Z_i\) and use \(\sum_iZ_i=m\). Aim for: \(D=\tau+\frac1m\sum_i(2Z_i-1)a_i\).

Hint 4 of 4: step 2

Take expectations when the assignment is random, then ask what \(D-\tau\) is when the assignment is fixed and the \(a_i\) drift with time. Aim for: zero in the first case and the difference of the group means of the \(a_i\) in the second.

Proof

Let \(Z_i=1\) if unit \(i\) gets level 2 and 0 otherwise. Then \[ D=\frac1m\sum_iZ_i(a_i+\tau)-\frac1m\sum_i(1-Z_i)a_i=\tau\cdot\frac1m\sum_iZ_i+\frac1m\sum_i(2Z_i-1)a_i=\tau+\frac1m\sum_i(2Z_i-1)a_i, \] using \(\sum_iZ_i=m\). By symmetry each unit is equally likely to be in the level-2 set, \(\P(Z_i=1)=m/N=\tfrac12\), so \(\E(2Z_i-1)=0\) for every \(i\), and by linearity \(\E D=\tau\) for any \(a_1,\dots,a_N\). That is, randomization makes the assignment independent of everything about the units, measured or not.

If the assignment is fixed in advance, \(Z\) is not random and \(D-\tau=\frac1m\sum_i(2Z_i-1)a_i\) is just the difference between the means of the \(a_i\) in the two groups. If the units are in time order with a drift, \(a_i=\gamma i\), and level 2 is applied to the last \(m\) units, this difference is \(\gamma\cdot N/2\), which grows with the run length instead of averaging out. The same argument within each block gives the unbiasedness of randomized block comparisons.

Consequence for Case Study 8.2.4. Aspirin was always given between the two measurements, so "after" cannot be randomized and any change over three hours (fatigue, diet, time of day) is part of \(\mu_D\); a control group given a placebo, with the order of the placebo and aspirin randomized, would remove this. ∎

Regression and correlation data

pp. 435–436 The designs so far had similar units and compared factor levels. In regression/correlation data the units are dissimilar and the aim is the functional relation between the variables. Regression data are pairs \((x_i,Y_i)\), \(x_i\) a (usually preselected) independent variable and \(Y_i\) a random response; the simple linear model is \[ Y_i=\beta_0+\beta_1x_i+\varepsilon_i,\qquad\varepsilon_i\sim\N(0,\sigma^2)\ \text{independent},\quad i=1,\dots,n, \] and \(\E Y_i=\beta_0+\beta_1x_i\) could be any function \(g(x_i)\). Adding \(k\) predictors gives multiple regression \(Y_i=\beta_0+\beta_1x_{1i}+\dots+\beta_kx_{ki}+\varepsilon_i\). When the \(x_i\) are not chosen but observed, as the heights \(X_i\) and weights \(Y_i\) of a random sample of men, both are random and the data \((X_i,Y_i)\) are correlation data, usually modelled by a bivariate normal law (Figure 8.2.2). The book states that if the aim is a straight line it "makes absolutely no difference" whether the data are \((x_i,Y_i)\) or \((X_i,Y_i)\); Chapter 11 explores the differences for inference.

Left: a wireframe bell-shaped surface over the (x, y) plane, elongated along the diagonal. Right: elliptical contour lines of the same density, tilted along the diagonal.
Figure 8.2.2. A bivariate normal density, here with correlation 0.6: a bell-shaped surface whose contours are ellipses tilted along the line of the positive correlation. Reproduces Larsen and Marx (2018), Figure 8.2.2 (the book draws a sketch; this one is computed). Code: ch08_types_of_data.py, fig_8_2_2.

Filling the gap 8.6: the least-squares line is the same for chosen and for observed \(x\), and a bivariate normal law is a regression model p. 436

The book asserts that it "makes absolutely no difference" for the fitted line whether the \(x\)'s are preselected or random, and that correlation data are "usually" bivariate normal. Two facts make this precise. (a) The least-squares line minimises \(\sum_i(y_i-b_0-b_1x_i)^2\), a function of the observed pairs only, with solution \(b_1=S_{xy}/S_{xx}\), \(b_0=\bar y-b_1\bar x\), where \(S_{xy}=\sum(x_i-\bar x)(y_i-\bar y)\) and \(S_{xx}=\sum(x_i-\bar x)^2\); nothing in the derivation mentions how the \(x_i\) arose. (b) If \((X,Y)\) is bivariate normal with means \(\mu_X,\mu_Y\), standard deviations \(\sigma_X,\sigma_Y\) and correlation \(\rho\), then given \(X=x\) the variable \(Y\) is \(\N\bigl(\beta_0+\beta_1x,\ \sigma_Y^2(1-\rho^2)\bigr)\) with \(\beta_1=\rho\sigma_Y/\sigma_X\) and \(\beta_0=\mu_Y-\beta_1\mu_X\): conditionally on the observed \(X_i\), the data satisfy exactly the regression model with \(x_i=X_i\).

Hint 1 of 5: the key idea

(a) Where in the derivation of the least-squares line does the origin of the \(x_i\) enter? (b) Remove from \(Y\) the part that is linear in \(X\): what is left, and why is it independent of \(X\)?

Hint 2 of 5: tools you will need
  • Setting partial derivatives to zero; a convex quadratic has a unique minimum.
  • Jointly normal and uncorrelated implies independent.
  • Linear functions of a bivariate normal pair are bivariate normal.
Hint 3 of 5: part (a)

Differentiate \(Q(b_0,b_1)=\sum(y_i-b_0-b_1x_i)^2\) and solve. Aim for: \(b_1=S_{xy}/S_{xx}\) and \(b_0=\bar y-b_1\bar x\), using only the observed pairs.

Hint 4 of 5: part (b), step 1

Put \(\beta_1=\Cov(X,Y)/\V X\) and \(\varepsilon=Y-\mu_Y-\beta_1(X-\mu_X)\). Aim for: \(\Cov(\varepsilon,X)=0\), hence independence of \(\varepsilon\) and \(X\).

Hint 5 of 5: part (b), step 2

Condition on \(X=x\) and compute \(\V\varepsilon\) by expanding. Aim for: \(\sigma_Y^2(1-\rho^2)\), constant in \(x\), and slope \(\rho\sigma_Y/\sigma_X\).

Proof

(a) Set the partial derivatives of \(Q(b_0,b_1)=\sum(y_i-b_0-b_1x_i)^2\) to zero: \(\sum(y_i-b_0-b_1x_i)=0\) gives \(b_0=\bar y-b_1\bar x\); substituting in \(\sum x_i(y_i-b_0-b_1x_i)=0\) and using \(\sum x_i(y_i-\bar y)=S_{xy}\), \(\sum x_i(x_i-\bar x)=S_{xx}\) gives \(b_1S_{xx}=S_{xy}\). \(Q\) is a convex quadratic, so this is the minimum when \(S_{xx}>0\). The formulas use the data only; they are the same whether \(x_i\) is fixed or the realised value of a random \(X_i\). What differs is the sampling distribution of \((b_0,b_1)\) unconditionally, the model for \(\rho\) and its tests (Chapter 11).

(b) Put \(\varepsilon=Y-\mu_Y-\beta_1(X-\mu_X)\) with \(\beta_1=\Cov(X,Y)/\V X=\rho\sigma_Y/\sigma_X\). Then \(\Cov(\varepsilon,X)=\Cov(Y,X)-\beta_1\V X=0\). The pair \((X,\varepsilon)\) is a linear function of the bivariate normal pair \((X,Y)\), so it is bivariate normal, and uncorrelated jointly normal variables are independent. Hence given \(X=x\), \(Y=\mu_Y+\beta_1(x-\mu_X)+\varepsilon\) with \(\varepsilon\sim\N(0,\V\varepsilon)\) not depending on \(x\), and \(\V\varepsilon=\sigma_Y^2-2\beta_1\Cov(X,Y)+\beta_1^2\sigma_X^2=\sigma_Y^2-\rho^2\sigma_Y^2\). This is the simple linear model with constant error variance \(\sigma_Y^2(1-\rho^2)\), and a unit change in \(x\) moves the mean of \(Y\) by \(\beta_1=\rho\,\sigma_Y/\sigma_X\). ∎

Case Study 8.2.6: Hubble and the expanding universe pp. 436–437

In 1929 Hubble reported that the galaxies recede from us, faster the farther they are: \(v=Hd\), with \(H\) Hubble's constant. The velocity \(v\) (thousands of miles per second) and distance \(d\) (millions of light-years) of eleven galactic clusters give the book's estimate \(H=0.03544\). Data: Case Study 8.2.6 (Table 8.2.6).

ClusterDistance \(d\) (millions of light-years)Velocity \(v\) (thousand miles/s)
Virgo220.75
Pegasus682.4
Perseus1083.2
Coma Berenices1374.7
Ursa Major No. 12559.3
Leo31512.0
Corona Borealis39013.4
Gemini40514.4
Bootes68524.5
Ursa Major No. 270026.0
Hydra110038.0

The units differ and the aim is a relation: regression data. Since \(d\) was not chosen (the clusters are those that could be measured) both variables are random and the straight-line fit is the same as the regression of \(v\) on \(d\) (Filling the gap 8.6). Chapter 11 develops the estimation of \(H\); Filling the gap 8.7 does it here, together with the book's conversion of \(H\) into the age of the universe.

Eleven dots lying close to a straight line through the origin, velocity from 0.75 to 38 against distance from 22 to 1100, with the line v = 0.03544 d drawn in red.
Figure 8.2.3. Distance and recession velocity of eleven galactic clusters, with the least-squares line through the origin \(v=0.03544\,d\). Reproduces Larsen and Marx (2018), Figure 8.2.3. Code: ch08_types_of_data.py, fig_8_2_3.

Filling the gap 8.7: the estimate \(H=0.03544\) and the age of the universe in years pp. 436–437

The book states that \(H\) "is estimated from these data to be 0.03544 (using a technique covered in Chapter 11)" and then converts it, through the units, to "approximately 5.2 billion years". The estimate is the least-squares slope through the origin, \(\hat H=\sum d_iv_i/\sum d_i^2\); the age is \(1/H\) once the units are converted. With the book's conversion factor, \(1/H\) is 5.26 billion years.

Hint 1 of 5: the key idea

A line through the origin has one parameter. Minimise the sum of squared vertical distances over that one parameter, then ask what the units of the answer mean.

Hint 2 of 5: tools you will need
  • Differentiate a quadratic and set to zero.
  • Unit conversion: miles per second per million light-years, and miles in a million light-years.
  • \(d=vt\) with the same \(t\) for every galaxy.
Hint 3 of 5: step 1

Minimise \(S(H)=\sum(v_i-Hd_i)^2\). Aim for: \(\hat H=\sum d_iv_i/\sum d_i^2\), and the numbers \(\sum d_iv_i=95161.2\), \(\sum d_i^2=2685141\).

Hint 4 of 5: step 2

Write \(H\) as miles per second divided by miles, so that it is a rate in \(\mathrm{s}^{-1}\). Aim for: \(H\approx6\times10^{-18}\,\mathrm{s}^{-1}\).

Hint 5 of 5: step 3

Take \(t=1/H\) and convert seconds to years. Aim for: about \(5.3\times10^9\) years. Which of 5.2 and 5.3 is the correct rounding?

Proof

Hubble's law has no intercept (zero distance means zero velocity), so minimise \(S(H)=\sum_i(v_i-Hd_i)^2\). \(S'(H)=-2\sum d_i(v_i-Hd_i)=0\) gives \(\hat H=\sum d_iv_i/\sum d_i^2\), and \(S''=2\sum d_i^2>0\) so it is a minimum. For the eleven clusters \(\sum d_iv_i=95161.2\) and \(\sum d_i^2=2\,685\,141\), so \(\hat H=0.035440\). (A line with an intercept has slope 0.0353, almost the same, because the fitted intercept is small.)

Units. \(v=Hd\) means velocity per distance, so \(H\) is 0.03544 thousand miles per second per million light-years, that is 35.44 miles per second for each \(5.8785\times10^{18}\) miles (the miles in a million light-years). So \[ H=\frac{35.44\ \text{mi/s}}{5.8785\times10^{18}\ \text{mi}}=6.029\times10^{-18}\ \text{s}^{-1}. \] If each galaxy has moved away at its present speed since the beginning, \(d=vt\) with the same \(t=d/v=1/H\) for all of them, and \(1/H=1.659\times10^{17}\) s. Dividing by \(3.156\times10^7\) s per year gives \(5.256\times10^{9}\) years. (The book writes about 5.2 billion; the unrounded value is 5.26.) The discrepancy with today's figure, well over ten billion years, is due to the revision of the distance scale, as the book says: the modern slope is about a third of Hubble's, and \(1/H\) is three times larger. ∎

Categorical data

pp. 437–438 Two qualitative variables recorded on \(n\) subjects, with \(R\) and \(C\) possible values, give categorical data. The counts of subjects in each of the \(RC\) combinations form a contingency table with \(R\) rows and \(C\) columns, and the question the data answer is whether the two variables are independent. The tool is the chi-squared test of independence (Chapter 10; the goodness-of-fit version appeared in the book's Section 7.5).

Case Study 8.2.7: birth order and juvenile delinquency p. 438

Of 1154 girls in public high schools, each answered a questionnaire on delinquent behaviour and gave her birth order. Data: Case Study 8.2.7 (Table 8.2.7).

OldestIn betweenYoungestOnly child
Delinquent: yes24293523
Delinquent: no45031221170
Total47434124693
% yes5.18.514.224.7

If delinquency and birth order were independent, the percentage of yeses would be about the same in every column; it rises from 5.1% to 24.7%. Overall \(111/1154=9.6\%\) of the girls answered yes, so independence would put about \(0.096\cdot474=45.6\) yeses among the oldest girls (observed 24) and \(0.096\cdot93=8.9\) among only children (observed 23). Filling the gap 8.8 explains these expected counts. Chapter 10 shows that the P-value of the chi-squared statistic, \(\chi^2=42.2\) on 3 degrees of freedom, is about \(4\times10^{-9}\): the evidence against independence is overwhelming. The book adds the caution that other studies find other patterns or none, so either the effect is weak or "delinquency" means different things to different researchers: a significant association in one sample is not a causal law.

Filling the gap 8.8: independence means equal conditional rates; for a 2 × 2 table the chi-squared statistic is \(z^2\) pp. 437–438, 443

The book says that under independence the percentages of yeses "would be similar" and that categorical data are tested by a chi-squared test. Two facts fill in what "similar" and "expect" mean. (a) With row classes \(A_i\) and column classes \(B_j\), independence \(\P(A_i\cap B_j)=\P(A_i)\P(B_j)\) for all \(i,j\) is the same as \(\P(B_j\mid A_i)=\P(B_j)\) for all \(i,j\): every row has the same conditional distribution of columns. With row totals \(r_i\), column totals \(c_j\) and \(n\) subjects, the natural expected counts under independence are \(E_{ij}=r_ic_j/n\). (b) For a \(2\times2\) table \(\bigl(\begin{smallmatrix}a&b\\c&d\end{smallmatrix}\bigr)\) with \(n=a+b+c+d\), the Pearson statistic \(\chi^2=\sum(O-E)^2/E\) equals \(n(ad-bc)^2/\bigl[(a+b)(c+d)(a+c)(b+d)\bigr]\), and this is also the square of the pooled \(z\) statistic for comparing the two proportions \(a/(a+b)\) and \(c/(c+d)\). So two samples of Bernoulli trials and a two-by-two table are the same test.

Hint 1 of 5: the key idea

(a) Independence of two classifications says that learning the row tells you nothing about the column. (b) For a two-by-two table, compute \(O-E\) in one cell and see how the margins force the other three.

Hint 2 of 5: tools you will need
  • Definition of conditional probability and of independence.
  • Estimating probabilities by relative frequencies of the margins.
  • The pooled estimate \(\hat p=c_1/n\) under \(H_0\colon p_1=p_2\) (Section 6.3).
Hint 3 of 5: part (a)

Show \(\P(A_i\cap B_j)=\P(A_i)\P(B_j)\iff\P(B_j\mid A_i)=\P(B_j)\). Aim for: expected count \(r_ic_j/n\).

Hint 4 of 5: part (b), step 1

Compute \(a-r_1c_1/n\) and expand \(an\). Aim for: \((ad-bc)/n\), the same size in every cell.

Hint 5 of 5: part (b), step 2

Sum \(1/E_{ij}\) as a product \((1/r_1+1/r_2)(1/c_1+1/c_2)\) times \(n\). Aim for: \(\chi^2=n(ad-bc)^2/(r_1r_2c_1c_2)\). Then do the same for \(z^2\) with the pooled variance.

Proof

(a) If \(\P(A_i\cap B_j)=\P(A_i)\P(B_j)\) then \(\P(B_j\mid A_i)=\P(A_i\cap B_j)/\P(A_i)=\P(B_j)\) when \(\P(A_i)>0\), which does not depend on \(i\); conversely \(\P(B_j\mid A_i)=\P(B_j)\) gives the product. Estimating \(\P(A_i)\) by \(r_i/n\) and \(\P(B_j)\) by \(c_j/n\), the expected count in cell \((i,j)\) is \(n\cdot\frac{r_i}n\cdot\frac{c_j}n=r_ic_j/n\). In Table 8.2.7 the "yes" row total is \(111\) and the oldest column has \(474\) girls out of \(1154\), hence \(E=111\cdot474/1154=45.6\).

(b) Let \(r_1=a+b\), \(r_2=c+d\), \(c_1=a+c\), \(c_2=b+d\). First, \(a-E_a=a-\frac{r_1c_1}{n}=\frac{an-(a+b)(a+c)}{n}=\frac{ad-bc}{n}\) (expand \(an=a^2+ab+ac+ad\)). The same computation gives \(|O-E|=|ad-bc|/n\) in every cell (the margins force the four deviations to be \(\pm\) the same number). Then \[\chi^2=\frac{(ad-bc)^2}{n^2}\sum_{i,j}\frac1{E_{ij}}=\frac{(ad-bc)^2}{n^2}\cdot n\Bigl(\frac1{r_1}+\frac1{r_2}\Bigr)\Bigl(\frac1{c_1}+\frac1{c_2}\Bigr)=\frac{(ad-bc)^2}{n}\cdot\frac{n}{r_1r_2}\cdot\frac{n}{c_1c_2}=\frac{n(ad-bc)^2}{r_1r_2c_1c_2}.\] For the \(z\) statistic, \(\hat p_1=a/r_1\), \(\hat p_2=c/r_2\), pooled \(\hat p=c_1/n\); the numerator is \(\hat p_1-\hat p_2=\frac{ar_2-cr_1}{r_1r_2}=\frac{ad-bc}{r_1r_2}\) and \(\hat p(1-\hat p)\bigl(\frac1{r_1}+\frac1{r_2}\bigr)=\frac{c_1c_2}{n^2}\cdot\frac{n}{r_1r_2}\). Hence \(z^2=\frac{(ad-bc)^2}{(r_1r_2)^2}\cdot\frac{nr_1r_2}{c_1c_2}=\frac{n(ad-bc)^2}{r_1r_2c_1c_2}=\chi^2\). ∎

Illustration (Case Study 8.1.4). For the stalkers, \(ad-bc=40-100=-60\), \(n=34\), so \(\chi^2=34\cdot3600/(14\cdot20\cdot14\cdot20)=1.561\) and \(z=1.25\); \(\P(\chi^2_1\ge1.561)=0.21\). The 29% and 50% white-collar percentages are not significantly different with so few people. The flow chart cannot see this overlap, because a 0/1 response looks quantitative to question 1 while the same data summarised as counts look qualitative. See also the chi-squared test of independence demonstration (preset 1, a two-by-two table).

Factorial data

p. 439 Factorial data are multifactor designs. With two factors, \(A\) with \(r\) levels and \(B\) with \(c\) levels, \(n\) independent replicates are taken at each of the \(rc\) combinations. In practice two to four factors are used. Every factor is fixed or random, and for factorial data the distinction matters (Chapter 15 of the book). Two questions arise: which factors have an effect on the response, and do any interact, that is, is the joint effect of \(A_i\) and \(B_j\) different from the sum of the effects of each alone? Often the second question is the more important.

Case Study 8.2.8: figure heights drawn by children in Barbados pp. 439–440

Psychologists use the height of the human figures that children draw as a measure of their view of parents. A four-factor study had factors sex of the child (boy or girl), age (elementary or high school), type of figure drawn (male or female) and family structure (mother only, or mother and father), each with two levels, giving \(2^4=16\) combinations, with the average figure height recorded for each (Table 8.2.8, not reproduced here). In every one of the 16 combinations the female figures were taller on average than the male ones. In the United States boys draw male figures taller, so these data are unusual; the explanation is where the data were collected, Barbados, a society in which mothers play a prominent role in raising children, which supports the claim that figure heights reflect the child-parent relation. This is a factorial design: more than one factor, each of intrinsic interest, with the measurement made at every combination of levels.

Filling the gap 8.9: what an interaction is, and why it can matter more than the main effects p. 439

The book defines interaction in words ("the joint effect differs from the sum of the individual effects") and asserts that its answer is often more important. For a \(2\times2\) design with cell means \(\mu_{ij}\) (factor \(A\) at level \(i\), factor \(B\) at level \(j\)), write main effects \(\alpha_i=\mu_{i\cdot}-\mu_{\cdot\cdot}\), \(\beta_j=\mu_{\cdot j}-\mu_{\cdot\cdot}\) and interaction \(\gamma_{ij}=\mu_{ij}-\mu_{i\cdot}-\mu_{\cdot j}+\mu_{\cdot\cdot}\), so that \(\mu_{ij}=\mu_{\cdot\cdot}+\alpha_i+\beta_j+\gamma_{ij}\). Then the effects are additive (all \(\gamma_{ij}=0\)) if and only if the single contrast \((\mu_{11}-\mu_{12})-(\mu_{21}-\mu_{22})\) is zero, i.e. the effect of \(B\) is the same at both levels of \(A\); and both main effects can vanish while the interaction is large.

Hint 1 of 4: the key idea

If the effect of \(B\) is the same at both levels of \(A\), the table of means is a sum of a row term and a column term. What single number measures departure from that, and can the row and column averages see it?

Hint 2 of 4: tools you will need
  • Row means, column means and the grand mean of a \(2\times2\) table.
  • The decomposition \(\mu_{ij}=\mu_{\cdot\cdot}+\alpha_i+\beta_j+\gamma_{ij}\).
  • Rows and columns of \((\gamma_{ij})\) sum to zero by construction.
Hint 3 of 4: step 1

Compute \(\gamma_{11}\) from its definition. Aim for: \(\gamma_{11}=(\mu_{11}-\mu_{12}-\mu_{21}+\mu_{22})/4\), and the other three are \(\pm\gamma_{11}\).

Hint 4 of 4: step 2

Take means \(\begin{pmatrix}10&20\\20&10\end{pmatrix}\) and compute the row and column means. Aim for: both main effects zero while the effect of \(B\) is \(+10\) at one level of \(A\) and \(-10\) at the other.

Proof

Direct computation gives \(\gamma_{11}=\mu_{11}-\frac{\mu_{11}+\mu_{12}}2-\frac{\mu_{11}+\mu_{21}}2+\frac{\mu_{11}+\mu_{12}+\mu_{21}+\mu_{22}}4=\frac{\mu_{11}-\mu_{12}-\mu_{21}+\mu_{22}}4\). The other three are \(\gamma_{12}=-\gamma_{11}\), \(\gamma_{21}=-\gamma_{11}\), \(\gamma_{22}=\gamma_{11}\) (each row and each column of \((\gamma_{ij})\) sums to 0 by construction). So all four vanish iff \(\gamma_{11}=0\), iff \((\mu_{11}-\mu_{12})-(\mu_{21}-\mu_{22})=4\gamma_{11}=0\), that is, the effect of changing \(B\) is the same at both levels of \(A\): additivity. If instead the means are \(\mu=\bigl(\begin{smallmatrix}10&20\\20&10\end{smallmatrix}\bigr)\), every row mean and column mean is 15, so \(\alpha_i=\beta_j=0\): "neither factor has an effect on average". But changing \(B\) raises the mean by 10 at \(A_1\) and lowers it by 10 at \(A_2\); the interaction contrast is \(-20\). A summary by main effects alone would say that nothing matters, when each factor matters a great deal and in opposite directions.

Two practical notes. With one observation per cell there are as many means as cells, so no degrees of freedom remain to estimate \(\sigma^2\) or to test the interaction; this is why factorial designs take replicates in each cell, which the book contrasts with pairs and blocks, where replication within a block is never done. And for \(A\) and \(B\) with more levels, the \(\gamma_{ij}\) defined above still sum to 0 over each row and column; additivity again means all of them vanish (Chapter 15 of the book). ∎

The flow chart and its overlaps

pp. 440–441 The five questions of the table above, drawn as a tree, form the flow chart of Figure 8.2.4. Usually a data set belongs to one and only one of the eight designs, but the chart shows two exceptions. If the answers are quantitative, similar, one factor, two levels and dependent, the data qualify as both paired and randomized block (a block design with \(k=2\)); if they are quantitative, similar, one factor, two levels and independent, as both two-sample and k-sample (with \(k=2\)). The book says the conclusions of the two analyses are then identical, and adds that a third overlap, not visible in the chart, is discussed in Chapter 11. The next box shows why the first two analyses agree.

Filling the gap 8.10: for two levels the analysis-of-variance \(F\) is the square of the \(t\) statistic p. 440

The book asserts that overlapping designs "end up testing the same hypotheses" with "exactly the same" inferences, without showing it. Define the analysis-of-variance ratio for a randomized block design as \(F=\dfrac{\mathrm{SS}_{\text{levels}}/(k-1)}{\mathrm{SS}_{\text{error}}/((b-1)(k-1))}\) (gap 8.4) and for a k-sample design as \(F=\dfrac{\mathrm{SSB}/(k-1)}{\mathrm{SSW}/(n-k)}\) (gap 8.2). Then for \(k=2\): (a) the paired \(t\) statistic \(t=\bar d/(s_d/\sqrt b)\) satisfies \(t^2=F_{\mathrm{RB}}\); (b) the pooled two-sample statistic \(t=(\bar x-\bar y)/\bigl(s_p\sqrt{1/n_1+1/n_2}\bigr)\) satisfies \(t^2=F_{\mathrm{k\text{-}sample}}\). Since \(t_{\nu}^2\) has the \(F_{1,\nu}\) law, the tests reject for the same data: \(t_{\alpha/2,\nu}^2=F_{\alpha;1,\nu}\).

Hint 1 of 5: the key idea

For two levels each sum of squares collapses to a multiple of one squared difference. Write the level sum of squares and the error mean square in terms of the paired differences \(d_i\), and compare with \(t^2\).

Hint 2 of 5: tools you will need
  • The definitions of the two \(F\) ratios (gap 8.2, gap 8.4).
  • \(t_\nu=Z/\sqrt{V/\nu}\) with \(Z\sim\N(0,1)\), \(V\sim\chi^2_\nu\) independent.
  • The pooled variance \(s_p^2\).
Hint 3 of 5: part (a)

With \(k=2\) find the grand mean and the residuals \(x_i-\bar x_{i\cdot}-\bar x+m\). Aim for: \(\mathrm{SS}_{\text{levels}}=b\bar d^{\,2}/2\), \(\mathrm{SS}_{\text{error}}=(b-1)s_d^2/2\), hence \(F=\bar d^{\,2}/(s_d^2/b)\).

Hint 4 of 5: part (b)

Express \(\bar x-\bar y_\cdot\) and \(\bar y-\bar y_\cdot\) through \(\bar x-\bar y\). Aim for: \(\mathrm{SSB}=\frac{n_1n_2}{n_1+n_2}(\bar x-\bar y)^2\) and \(\mathrm{SSW}=(n-2)s_p^2\).

Hint 5 of 5: part (c)

Square the representation of \(t_\nu\) and recognise a ratio of independent chi-squared variables over their degrees of freedom. What does this say about the cut-offs of the two tests?

Proof

(a) Let the pair \(i\) be \((x_i,y_i)\), \(d_i=x_i-y_i\), \(\bar d=\bar x-\bar y\), \(m=(\bar x+\bar y)/2\) the grand mean, and \(b\) the number of pairs. Level sum of squares: \(b[(\bar x-m)^2+(\bar y-m)^2]=b\,\bar d^{\,2}/2\), one degree of freedom. The residual for \(x_i\) is \(x_i-\frac{x_i+y_i}{2}-\bar x+m=\frac{d_i-\bar d}{2}\) and for \(y_i\) it is the negative of that, so \(\mathrm{SS}_{\text{error}}=2\sum_i\frac{(d_i-\bar d)^2}4=\frac{(b-1)s_d^2}2\) on \((b-1)\) degrees of freedom, a mean square \(s_d^2/2\). Therefore \[F_{\mathrm{RB}}=\frac{b\,\bar d^{\,2}/2}{s_d^2/2}=\frac{\bar d^{\,2}}{s_d^2/b}=t^2.\]

(b) With \(k=2\), \(\bar y_\cdot\) the grand mean, \(\mathrm{SSB}=n_1(\bar x-\bar y_\cdot)^2+n_2(\bar y-\bar y_\cdot)^2\). Since \(\bar y_\cdot=(n_1\bar x+n_2\bar y)/n\), \(\bar x-\bar y_\cdot=\frac{n_2}{n}(\bar x-\bar y)\) and \(\bar y-\bar y_\cdot=-\frac{n_1}{n}(\bar x-\bar y)\), so \(\mathrm{SSB}=\bigl(\frac{n_1n_2^2+n_2n_1^2}{n^2}\bigr)(\bar x-\bar y)^2=\frac{n_1n_2}{n_1+n_2}(\bar x-\bar y)^2\), one degree of freedom. \(\mathrm{SSW}=(n_1-1)s_x^2+(n_2-1)s_y^2=(n-2)s_p^2\), a mean square \(s_p^2\). So \(F=\frac{n_1n_2}{n_1+n_2}\cdot\frac{(\bar x-\bar y)^2}{s_p^2}=\frac{(\bar x-\bar y)^2}{s_p^2(1/n_1+1/n_2)}=t^2\).

Finally, if \(T\sim t_\nu\), \(T=Z/\sqrt{V/\nu}\) with \(Z\sim\N(0,1)\) and \(V\sim\chi^2_\nu\) independent, so \(T^2=Z^2/(V/\nu)\), a ratio of independent \(\chi_1^2/1\) and \(\chi_\nu^2/\nu\): the \(F_{1,\nu}\) law. Then \(\P(|T|\ge t_{\alpha/2,\nu})=\alpha\) is \(\P(T^2\ge t_{\alpha/2,\nu}^2)=\alpha\), so \(t_{\alpha/2,\nu}^2=F_{\alpha;1,\nu}\), the two-sided \(t\) test and the \(F\) test reject on the same events. ∎

Illustration. For the aspirin differences \(t=0.740\) and the randomized block ratio computed on the \(12\times2\) table is \(F=0.548=0.740^2\); for the bait data (not an overlap, \(k=4\)) no such identity exists. For any table of numbers one can check the identity: the two sums of squares are just a rearrangement of \(d_i\) or of the two group means.

Using the flow chart: Examples 8.2.1 to 8.2.3

pp. 441–443 Three examples train the eye. Each answers the five questions in turn.

Example 8.2.1: sulfite in wine, a new measurement method against the standard pp. 441–442

Sulfite ions occur naturally in wine and are added to prolong shelf life, but high levels cause breathing problems, so their concentration is regulated. A new infrared method (DRS-FTIR) is proposed as an easier alternative to the standard laboratory method. To compare them, the concentration was measured by both methods on two white and two red wines (Table 8.2.9). Classification. Concentrations are quantitative and in the same units; the one factor is "method" with two levels. "Type of wine" is not a second factor: the wines are labelled generically (White wine 1, Red wine 2) because nobody cares about those particular wines, they merely supply four environments. The two numbers in a row share a wine, so they are dependent: paired data (equivalently randomized block with \(k=2\)). The aim is unusual: the researchers hope not to reject \(H_0\colon\mu_D=0\) (the two methods agree), which makes the power of the test and the size of a difference worth detecting the real question (Section 6.6), not the P-value.

Example 8.2.2: butterflies in a logged rainforest pp. 442–443

In a Borneo rainforest, butterfly species were counted in eight tracts: four primary (never logged) and four logged six years earlier. Two of each kind were on ridge tops and two were by rivers (Table 8.2.10); the counts are numbers of species. Classification. Quantitative, same units; two factors, forest type (primary, logged) and elevation (ridge-top, river-side), because the two elevations are distinct, well-defined ecosystems that interest the researchers in their own right, unlike the wines. Two replicates sit in every combination (every pair of levels), and replication in the cell is characteristic of factorial data and never done for pairs or blocks. (The book notes that, contrary to expectation, more species were found in the logged sites than the primary ones: possible explanations are that thinning the canopy improved the habitat, or that logging hurt the butterflies' predators.)

Example 8.2.3: cowbirds and indigo buntings p. 443

Brown-headed cowbirds lay their eggs in other birds' nests. In a study in southern Michigan, 693 indigo bunting nests were monitored: 556 were not parasitized, of which 315 fledged a bunting; of the \(693-556=137\) parasitized nests, 26 fledged a bunting. Classification. Two recorded variables, each with two outcomes (parasitized or not, fledged or not): both qualitative, so the first question already ends the search: categorical data, a \(2\times2\) table. The percentages fledged, \(315/556=56.7\%\) and \(26/137=19.0\%\), are far apart, so brood parasitism is plainly a threat. Chapter 10 would test independence; gap 8.8 shows this is the same test as comparing two proportions.

Notes on the book

The age of the universe: 5.26 billion years, not 5.2 p. 437

With \(H=0.03544\) and the book's own conversion factor, \(5.8785\times10^{18}\) miles per million light-years, \(1/H=1.659\times10^{17}\) s \(=5.256\times10^9\) years (Julian year of \(3.15576\times10^7\) s; a year of 365 days changes it only to 5.260). The book's "approximately 5.2 billion" truncates 5.26 instead of rounding to 5.3. The conclusion is unaffected. The derivation is in Filling the gap 8.7.

Marathon runners and ten-thousand-metre races p. 434

Case Study 8.2.5 introduces "marathon runners" but the races are over 10 000 m and the times in Table 8.2.5 are 31 to 35 minutes, which is not a marathon (42 km, over two hours). Only the description is affected, not the data or the analysis.

A remark on the aspirin data: "just about as well" p. 433

The book says that the two-sample format "might have done just about as well" for Table 8.2.4 and that the data "fall somewhere in between". In terms of the decision this is true: neither test rejects \(H_0\) (paired \(t=0.74\), unpaired \(t=0.37\)). In terms of precision it is not: the sample correlation is 0.76, the variance of the differences is 0.257 against 1.057 for independent samples, and the standard error is 0.146 against 0.297 (Filling the gap 8.3). The pair effect is clearly large enough for pairing to pay.

The third overlap pp. 440–441

The book says there are three measurement types that can be classified as two designs, shows two in the flow chart and defers the third to Chapter 11 without naming it. These notes treat the two the chart shows (Filling the gap 8.10) and the equivalence of two Bernoulli samples and a two-by-two table (gap 8.8), which the flow chart also cannot display; I cannot tell from the text which one the book means.

Selected questions

Five of the book's questions, restated in my own words. Questions 8.2.1 to 8.2.12 and 8.2.13 to 8.2.32 ask the reader to identify the design of a data set with the five questions of Section 8.2; the five selected cover regression (8.2.1), randomized blocks (8.2.4), pairs (8.2.6), k samples (8.2.7) and categorical data (8.2.20), and each solution adds a computation that shows what the design buys. Classifications were cross-checked with the book's answers to the odd-numbered questions (8.2.1 and 8.2.7), which they match; the others have no printed answer.

  1. Question 8.2.1 (Kepler's third law). Kepler's third law says that the squares of the planets' periods are proportional to the cubes of their mean distances from the Sun. The table gives, for the eight planets, the period \(x\) in years and the mean distance \(y\) in astronomical units: Mercury (0.241, 0.387), Venus (0.615, 0.723), Earth (1.000, 1.000), Mars (1.881, 1.524), Jupiter (11.86, 5.203), Saturn (29.46, 9.54), Uranus (84.01, 19.18), Neptune (164.8, 30.06). The book adds a column \(x^2/y^3\). Identify the design with the five questions. Then show how the data could be used to check the law: which model, which parameter value does the law predict, and what do the data give?

    Hint 1 of 5: the key idea

    Ask the five questions in order; the second one already ends the search. For testing the law, find a transformation that turns \(x^2=cy^3\) into a straight line.

    Hint 2 of 5: tools you will need
    • The table of five questions (Section 8.2).
    • Logarithms: \(\log(x^2)=2\log x\).
    • The least-squares line (gap 8.6).
    Hint 3 of 5: part (a)

    Are the variables quantitative? Are their units similar? Aim for: the name of the design, and a reason why the \(x^2/y^3\) column does not make it one-sample.

    Hint 4 of 5: part (b)

    Take logarithms of \(x^2=cy^3\). Aim for: a line \(\log x=\beta_0+\beta_1\log y\) with \(\beta_1=3/2\) and \(\beta_0=\frac12\log c\).

    Hint 5 of 5: part (c)

    Fit by least squares and compare \(\hat\beta_1\) with \(3/2\) and \(\hat\beta_0\) with 0. Aim for: \(\hat c=e^{2\hat\beta_0}\), close to 1.

    Solution

    Classification. Both variables are quantitative (question 1). The units are dissimilar, years against astronomical units (question 2), so the search ends: regression/correlation data, as the book's answer says. The extra column \(x^2/y^3\) is computed from the other two and does not make the data a one-sample design: the eight ratios are not independent draws of an experiment, they are values of a function that the law claims is constant. The values (1.002, 1.001, 1.000, 1.000, 0.999, 1.000, 1.000, 1.000) all lie within 0.002 of 1, which is as close to constant as the rounding of the inputs allows.

    A model to test the law. The law says \(x^2=c\,y^3\) for some constant \(c\). Taking logarithms, \(\log x=\tfrac12\log c+\tfrac32\log y\): a straight line in the variables \(\log y\) (predictor) and \(\log x\) (response) with slope exactly \(\beta_1=3/2\) and intercept \(\beta_0=\tfrac12\log c\); in these units the law predicts \(c=1\), so \(\beta_0=0\). The regression model of Section 8.2 is \(\log x_i=\beta_0+\beta_1\log y_i+\varepsilon_i\), here with almost no error.

    The fit. Least squares on the eight points (formulas of gap 8.6) gives \(\hat\beta_1=1.4998\) and \(\hat\beta_0=0.0002\), so \(\hat c=e^{2\hat\beta_0}=1.0005\). The slope is within 0.0002 of \(3/2\), and the intercept is zero to three decimals: the data confirm the law. (Being an exact physical law, the only scatter here is rounding; for noisy data a confidence interval for \(\beta_1\), Chapter 11, would decide whether \(3/2\) is plausible.)

  2. Question 8.2.4 (cockroaches and crowding). Ten groups of four male cockroaches were each subjected to three population densities, high, intermediate and low, and the number of serious fights per minute was recorded for each group at each density. The ten rows (high, intermediate, low) are: (0.30, 0.11, 0.12), (0.20, 0.24, 0.28), (0.17, 0.13, 0.20), (0.25, 0.36, 0.15), (0.27, 0.20, 0.31), (0.19, 0.12, 0.16), (0.27, 0.19, 0.20), (0.23, 0.08, 0.17), (0.37, 0.18, 0.18), (0.29, 0.20, 0.20). Identify the design, write its model equation, and compute how much of the total variation is due to the groups, to the densities and to the remainder. Would treating the 30 numbers as three independent samples have changed the analysis?

    Hint 1 of 5: the key idea

    Who is measured more than once? Observations on the same animals at all three densities share a background: which design has that structure?

    Hint 2 of 5: tools you will need
    • The five questions (Section 8.2) and the randomized block model.
    • The decomposition of gap 8.4.
    • Row means, column means and the grand mean.
    Hint 3 of 5: part (a)

    Answer the five questions. Aim for: the design, \(b\), \(k\), and why 'group' is a block rather than a second factor.

    Hint 4 of 5: part (b)

    Compute the total sum of squares, the block sum of squares \(k\sum(\bar y_{i\cdot}-\bar y)^2\) and the density sum of squares \(b\sum(\bar y_{\cdot j}-\bar y)^2\). Aim for: error by subtraction, and the share of the total due to blocks.

    Hint 5 of 5: part (c)

    Compare mean squares with and without removing the block sum of squares from the error. Aim for: two ratios, 3.56 and 3.31, and an explanation of why they are close here.

    Solution

    Classification. The responses are quantitative with the same units (fights per minute); there is one factor, density, with three levels; and the three numbers in a row come from the same four cockroaches, a shared background, so the samples are dependent. Following the table of Section 8.2: randomized block data, with \(b=10\) blocks (the groups) and \(k=3\) levels. The groups are not a second factor of interest: nobody cares about group 4 in particular, as in the wine example. The model is \(Y_{ij}=\mu_j+B_i+\varepsilon_{ij}\), \(i=1,\dots,10\), \(j=1,2,3\). (Order of the densities should be randomized within each group, gap 8.5; and treating the same animals, "repeated measures", is the standard way to make observations dependent.)

    The decomposition (gap 8.4). Column means 0.254, 0.181, 0.197 (the book prints 0.25, 0.18, 0.20), grand mean 0.2107. Total sum of squares 0.1496; blocks 0.0457 (31% of the total); densities 0.0294; error \(0.1496-0.0457-0.0294=0.0745\) on \((10-1)(3-1)=18\) degrees of freedom.

    Blocked or not. The ratio of mean squares for densities is \((0.0294/2)/(0.0745/18)=3.56\). If the groups were ignored and the data treated as three independent samples (k-sample), the error sum of squares would be \(0.1496-0.0294=0.1202\) on 27 degrees of freedom and the ratio \((0.0294/2)/(0.1202/27)=3.31\). Here blocking made a small difference, because the groups explain only 31% of the variation; for the bait data of Case Study 8.1.2, where they explain 85%, the ratio rises from 0.57 to 7.6. The chance to benefit from blocking is exactly the size of the block variation relative to the error.

  3. Question 8.2.6 (lambs and depth perception). Thirteen litters of lambs were used to see whether time with the mother speeds up depth perception. In each litter one lamb stayed with the ewe and the other was removed at birth. Each lamb was placed on a simulated cliff every hour until it first refused to step on the glass; the number of trials needed was recorded. Mothered \(x_i\): 2, 3, 5, 3, 2, 1, 1, 5, 3, 1, 7, 3, 5; unmothered \(y_i\), in the same litter order: 3, 11, 10, 5, 5, 4, 2, 7, 5, 4, 8, 12, 7. Identify the design and compute the differences. Compare the variance of the differences with what independent samples would give.

    Hint 1 of 5: the key idea

    Two lambs from one litter share genes and early life. What does that do to the five questions, and what does it do to the variance of the difference between the two numbers?

    Hint 2 of 5: tools you will need
    Hint 3 of 5: part (a)

    Classify the data and form the 13 differences \(d_i\). Aim for: the design, \(\bar d\) and \(s_d\).

    Hint 4 of 5: part (b)

    Compute the two sample variances and the covariance of the columns. Aim for: \(\V(d)\) against the sum of the two variances, and the two standard errors of the mean difference.

    Hint 5 of 5: part (c)

    Compare the paired statistic with the pooled statistic from the same numbers. Which assumption of the normal model looks doubtful for counts of this size?

    Solution

    Classification. Quantitative, same units (trials); one factor (time with the mother) with two levels; the two lambs of a litter share genes and early environment, so the observations are dependent: paired data, \(n=13\) pairs, \(X_i=\mu_X+P_i+\varepsilon_i\), \(Y_i=\mu_Y+P_i+\varepsilon_i'\) with \(P_i\) the litter effect. The hypotheses are about \(\mu_D=\mu_Y-\mu_X\) (the book would use \(X-Y\); the sign is conventional).

    The differences \(d_i=y_i-x_i\): 1, 8, 5, 2, 3, 3, 1, 2, 2, 3, 1, 9, 2. Mean \(\bar d=3.23\) trials, standard deviation \(s_d=2.59\), standard error \(2.59/\sqrt{13}=0.72\); the paired statistic is \(t=3.23/0.72=4.50\) on 12 degrees of freedom (Chapter 13).

    What pairing bought (gap 8.3). The sample variances are 3.47 (mothered) and 9.76 (unmothered), their covariance is 3.27 (littermate correlation 0.56). The variance of the differences is \(3.47+9.76-2(3.27)=6.69\), against \(3.47+9.76=13.23\) for independent samples; the standard errors of the mean difference are 0.72 and 1.01. Had the 26 lambs been treated as two independent samples the pooled statistic would be \(3.20\) on 24 degrees of freedom: still large, but the paired analysis is clearly stronger. A caution: the counts are small and right-skewed (the maximum 12 trials), so the normal-theory \(t\) approximations are rough; the nonparametric tests of Chapter 14 (sign test, signed-rank test) are the usual check.

  4. Question 8.2.7 (teachers' expectations). Fifteen first graders took a standard IQ test. The teachers were told it was a special test that predicts intellectual "spurts". The children were randomly split into groups of 6, 5 and 4; the teachers were told that group I would show no pronounced growth, group II moderate growth and group III exceptional growth. A year later the children were tested again. The changes in score (second minus first) were: group I: 3, 2, 6, 10, 10, 5; group II: 10, 4, 11, 14, 3; group III: 20, 9, 18, 19. Identify the design and its model equation. Compute the group means and the between and within sums of squares.

    Hint 1 of 5: the key idea

    Each child contributes one number, a difference of two test scores. Do children in different groups share anything, and is there a second number for the same child at another factor level?

    Hint 2 of 5: tools you will need
    • The five questions (Section 8.2).
    • The k-sample model \(Y_{ij}=\mu_j+\varepsilon_{ij}\).
    • The sums of squares of gap 8.2.
    Hint 3 of 5: part (a)

    Answer the five questions and explain why the before-and-after nature of the response does not make the design paired. Aim for: the design with \(k=3\) and \(n=15\).

    Hint 4 of 5: part (b)

    Compute the three group means and the grand mean, then \(\mathrm{SSB}=\sum n_j(\bar y_j-\bar y)^2\). Aim for: \(\mathrm{SSB}=275.4\).

    Hint 5 of 5: part (c)

    Get \(\mathrm{SSW}\) from the squared deviations within each group (or by subtracting from the total) and form the two mean squares. Aim for: \(\mathrm{SSW}=224.2\) on 12 degrees of freedom and a ratio near 7.4.

    Solution

    Classification. The response, the change in IQ score, is quantitative with one unit; the one factor is what the teacher was told, with three levels; and the children were randomly allocated to three distinct groups, so the three samples are independent: k-sample data, \(k=3\), \(n_1=6\), \(n_2=5\), \(n_3=4\), \(n=15\), \(Y_{ij}=\mu_j+\varepsilon_{ij}\), as the book's answer says. Each child was tested twice, but the data set holds one number per child (the difference): the before-and-after structure is absorbed into the response and creates no dependence between children, so this is not a paired design (pairs would be two numbers, one per level, for the same child). The assignment into groups by lottery is what makes the groups comparable (gap 8.5).

    Sums of squares (gap 8.2). The group means are \(6.0\), \(8.4\) and \(16.5\), the grand mean is \(144/15=9.6\). Between groups: \(6(6.0-9.6)^2+5(8.4-9.6)^2+4(16.5-9.6)^2=77.76+7.20+190.44=275.4\). Within groups: \(\mathrm{SSW}=224.2\) on \(n-k=12\) degrees of freedom; the total is \(499.6\). The mean squares are \(275.4/2=137.7\) and \(224.2/12=18.7\), a ratio of \(7.37\); under \(H_0\colon\mu_1=\mu_2=\mu_3\) both estimate \(\sigma^2\) and the ratio would be near 1, so the data point to a real difference (Chapter 12 gives the P-value).

  5. Question 8.2.20 (health-care opinion). A poll asked 120 senior citizens and 85 first-time voters whether they favour a complete overhaul of the health care system or more modest changes. Among the seniors, 65 favoured an overhaul and 55 modest changes; among the first-time voters, 40 and 45. Identify the design with the five questions, give the table and the expected counts under independence, and say what other design the same data also fit.

    Hint 1 of 5: the key idea

    What is recorded on each person: numbers or categories? The first of the five questions already decides the design. Then ask what independence of the two classifications would predict for every cell.

    Hint 2 of 5: tools you will need
    • The five questions (Section 8.2).
    • Expected counts \(r_ic_j/n\) and the chi-squared statistic (gap 8.8).
    • The pooled \(z\) statistic for two proportions.
    Hint 3 of 5: part (a)

    Make the \(2\times2\) table with its margins. Aim for: row totals 120 and 85, column totals 105 and 100, \(n=205\).

    Hint 4 of 5: part (b)

    Find the expected count of each cell and \(ad-bc\). Aim for: every \(|O-E|=|ad-bc|/n\), and \(\chi^2\) from the shortcut \(n(ad-bc)^2/(r_1r_2c_1c_2)\).

    Hint 5 of 5: part (c)

    The row totals were fixed by the poll. Which other design in the table is this, and what is \(z^2\)? Aim for: two independent Bernoulli samples and \(z^2=\chi^2\).

    Solution

    Classification. Two variables are recorded on every person: age group (senior or first-time voter) and opinion (overhaul or modest). Both are qualitative, so question 1 ends the search: categorical data, a \(2\times2\) contingency table \[\begin{array}{l|cc|c}&\text{overhaul}&\text{modest}&\text{total}\\\hline\text{senior}&65&55&120\\\text{first-time voter}&40&45&85\\\hline\text{total}&105&100&205\end{array}\] The percentages favouring an overhaul are \(65/120=54.2\%\) and \(40/85=47.1\%\).

    Expected counts. Under independence (gap 8.8) each cell expects row total times column total over \(n=205\): \(120\cdot105/205=61.5\) and \(120\cdot100/205=58.5\) for the seniors, \(85\cdot105/205=43.5\) and \(85\cdot100/205=41.5\) for the first-time voters. Every \(|O-E|\) equals \(|ad-bc|/n=|65\cdot45-55\cdot40|/205=725/205=3.54\), and \(\chi^2=205\cdot725^2/(120\cdot85\cdot105\cdot100)=1.006\) on 1 degree of freedom, with P-value 0.32: no evidence that the two groups differ.

    The overlap. The group sizes 120 and 85 were fixed by the poll, so the data are also two independent samples of Bernoulli trials (success: favours an overhaul), the two-sample design of p. 428 with \(H_0\colon p_X=p_Y\). The pooled statistic is \(z=(0.5417-0.4706)/\sqrt{0.5122\cdot0.4878\,(1/120+1/85)}=1.003\), and \(z^2=1.006\) equals the chi-squared statistic, so the two analyses are one test.

Demonstrations for this chapter

The chapter's one idea that benefits from a simulation, how much variance pairing removes and when it stops paying, is already covered by a first-year demonstration, so no new page was built. It opens already set to the case under discussion from the ▶ Demo box in Filling the gap 8.3.

DemonstrationWhat you can seeSections and results
Two samples: pooled or Welch, paired or not? (first-year course)The paired test and the same test with the pairing ignored, side by side, for a chosen correlation between the two measurements on a subject. Presets: 5 (correlation 0.85, 8 people: paired power about 96%, unpaired about 28%), 6 (correlation 0: pairing gains nothing).Section 8.2 (paired data, Filling the gap 8.3)
The chi-squared test of independence (graduate course)The statistic and its null distribution by simulation for tables of counts. Preset 1 is a two-by-two table.Section 8.2 (categorical data, Filling the gap 8.8)

References

  1. Cochran, W. G. and Cox, G. M. (1957). Experimental Designs, 2nd edition. Wiley, New York.
  2. Fisher, R. A. (1935). The Design of Experiments. Oliver and Boyd, Edinburgh.
  3. Hubble, E. (1929). A relation between distance and radial velocity among extra-galactic nebulae. Proceedings of the National Academy of Sciences, 15(3), 168–173.
  4. Larsen, R. J. and Marx, M. L. (2018). An Introduction to Mathematical Statistics and Its Applications, 6th edition. Pearson, Boston. Chapter 8, pp. 421–449.
  5. Pearson, K. (1900). On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine, Series 5, 50, 157–175.
  6. Student (W. S. Gosset) (1908). The probable error of a mean. Biometrika, 6(1), 1–25.