CalcPath
ProgressProblem setsFeedback
← Question sheet

Statistics · Solutions

Analysis of Variance

12 questions · about 108 minutes

Work this sheet on paper, showing every step — the method is what is being tested, and the solutions are written so you can check your route rather than just your answer. Name every result you use (“by the decomposition of the total sum of squares”, “by the expected mean squares”, “by Tukey's HSD”) and say which model you are working in, fixed or random. Every critical value you need is printed with its question and the arithmetic has been arranged to come out in exact fractions, so no calculator is needed. Full worked solutions are on a separate page; each question also has its own reveal, so you can check one answer without seeing the rest.

  1. 1.Computation

    Three brands of battery are tested for lifetime, in hours. The observations are

    Brand A: 2, 4, 6. Brand B: 5, 7, 7, 9, 7. Brand C: 8, 10, 12, 10.

    Use F0.05,2,9​=4.256, and keep every quantity as an exact fraction.

    1. (a)Compute the three group means, the grand mean, SSB and SSW. Explain why the grand mean is not (4+7+10)/3.
    2. (b)Write out the ANOVA table — sums of squares, degrees of freedom, mean squares — and the F statistic. Test H0​:μA​=μB​=μC​ at α=0.05, and state exactly what the conclusion does and does not say.
    3. (c)Compute SST directly from the twelve observations and confirm the decomposition of the total sum of squares, degrees of freedom included. Then compute η2 and say what it measures that the F-test does not.

    Solution

    (a) Group means and the grand mean. xˉA​=12/3=4, xˉB​=35/5=7, xˉC​=40/4=10. The grand mean is the mean of all N=3+5+4=12 observations, which is the group means weighted by group size:

    xˉ=1212+35+40​=1287​=429​.

    The unweighted average (4+7+10)/3=7 gives Brand A's three observations the same weight as Brand B's five. The grand mean has to reproduce the total, and 7×12=84=87.

    Between. The group means sit at 4−429​=−413​, 7−429​=−41​ and 10−429​=411​ from the grand mean, so

    SSB=i∑​ni​(xˉi​−xˉ)2=3⋅16169​+5⋅161​+4⋅16121​=16507+5+484​=16996​=4249​.

    Within. Deviations from each group's own mean. Brand A: −2,0,2, squares summing to 8. Brand B: −2,0,0,2,0, sum 8. Brand C: −2,0,2,0, sum 8. So SSW=24.

    (b) The table. Degrees of freedom are k−1=2 between and N−k=12−3=9 within. Then MSB=4249​⋅21​=8249​ and MSW=924​=38​, and

    F=MSWMSB​=8249​⋅83​=64747​≈11.67.

    In table form: Between — SS=249/4, df 2, MS=249/8; Within — SS=24, df 9, MS=8/3; Total — SS=345/4, df 11; F=747/64.

    Since 11.67>4.256, reject H0​ at the 5% level: the three brands do not all have the same mean lifetime. That is all it says. The alternative is “not all equal”, so the test does not identify which brands differ, and it does not say that all three differ from each other — a post-hoc procedure is needed for that.

    (c) The identity as an arithmetic check. First, ∑i,j​xij2​=(4+16+36)+(25+49+49+81+49)+(64+100+144+100)=56+253+408=717. Expanding the square, ∑(xij​−xˉ)2=∑xij2​−2xˉ∑xij​+Nxˉ2=∑xij2​−Nxˉ2, so

    SST=717−12⋅16841​=717−42523​=42868−2523​=4345​.

    And SSB+SSW=4249​+496​=4345​ ✓, by the decomposition of the total sum of squares. The degrees of freedom agree too: 2+9=11=N−1 ✓.

    Effect size:

    η2=SSTSSB​=345/4249/4​=345249​=11583​≈0.72.

    About 72% of the variation in lifetime is attributable to brand. That is a statement about how much brand matters. The F-test answers only whether any difference exists, and with enough data it rejects for differences of no practical size; η2 is what separates “detectable” from “large”.

  2. 2.Proof

    Let group i have ni​ observations xij​, mean xˉi​ and sample variance si2​=ni​−11​∑j​(xij​−xˉi​)2, and let N=∑i​ni​ with k groups. Prove each statement directly from these definitions.

    1. (a)The grand mean is xˉ=N1​∑i​ni​xˉi​, and with equal group sizes it is the plain average of the group means.
    2. (b)MSW=∑i​(ni​−1)∑i​(ni​−1)si2​​ — a weighted average of the group sample variances with weights ni​−1 — and with equal group sizes it is the plain average of the si2​.
    3. (c)If every group has the same sample variance s2, then MSW=s2 whatever the group sizes. Then say in one sentence what (b) predicts when the group sizes are unequal and the variances differ.

    Solution

    (a) The grand mean. By definition xˉ is the total divided by N. The total is a sum over groups of each group's total, and a group's total is ∑j​xij​=ni​xˉi​ by the definition of xˉi​. So

    xˉ=N1​i∑​j∑​xij​=N1​i∑​ni​xˉi​.

    If every ni​=n then N=kn and xˉ=kn1​∑i​nxˉi​=k1​∑i​xˉi​, the plain average. ■

    (b) Within mean square. By the definition of si2​, group i's within sum of squares is ∑j​(xij​−xˉi​)2=(ni​−1)si2​. Summing over groups,

    SSW=i∑​(ni​−1)si2​,andN−k=i∑​ni​−i∑​1=i∑​(ni​−1).

    Hence MSW=SSW/(N−k)=∑i​(ni​−1)si2​/∑i​(ni​−1), which is a weighted average of the si2​ because the weights ni​−1 are positive and the denominator is their sum. With all ni​=n the weights are all n−1, so

    MSW=k(n−1)(n−1)∑i​si2​​=k1​i∑​si2​.■

    (c) Equal variances. If si2​=s2 for every i, then by (b)

    MSW=∑i​(ni​−1)s2∑i​(ni​−1)​=s2,

    independently of the ni​. ■

    When the sizes and the variances are both unequal, (b) says MSW is pulled toward the variances of the large groups, since they carry most of the weight — so it understates the noise in the small groups if those are the more variable ones, and overstates it if they are the less variable ones.

  3. 3.Computation

    Three designs each compare k=3 groups. The group sizes and sample standard deviations are

    (i) n=(10,10,10), s=(2,6,6); (ii) n=(40,5,5), s=(2,6,6); (iii) n=(40,5,5), s=(6,2,2).

    1. (a)Compute MSW for each design as an exact fraction, and compare it with the variance of the two smaller groups (in (i), of groups 2 and 3).
    2. (b)For each design say whether the ordinary F-test is approximately valid, anti-conservative (rejects too often) or conservative, and explain the mechanism in terms of which groups carry the weight in MSW.
    3. (c)What single analysis would you recommend for (ii) and (iii)? Explain why a preliminary test of equal variances is not the right way to decide.

    Solution

    (a) The three MSW values. MSW is the weighted average ∑i​(ni​−1)si2​/(N−k), with weights ni​−1.

    (i) Weights 9,9,9 and variances 4,36,36:

    MSW=279⋅4+9⋅36+9⋅36​=27684​=376​≈25.3,

    the plain average of 4, 36 and 36. It sits between the group variances, closer to the 36 shared by two of the three groups.

    (ii) Weights 39,4,4 and variances 4,36,36:

    MSW=4739⋅4+4⋅36+4⋅36​=47156+144+144​=47444​≈9.4.

    The two small groups have variance 36, nearly four times MSW.

    (iii) Weights 39,4,4 and variances 36,4,4:

    MSW=4739⋅36+4⋅4+4⋅4​=471404+16+16​=471436​≈30.6.

    The two small groups have variance 4; MSW overstates their noise by a factor of about 721​.

    (b) Which way each design fails. In every design the variance ratio is 36/4=9, beyond the factor-of-four rule of thumb, so the difference between the designs is entirely the group sizes.

    (i) Approximately valid. With equal group sizes the weights are equal, MSW is a fair average, and the F-test is robust to unequal variances. The true level stays close to 5%.

    (ii) Anti-conservative. This is the dangerous pairing: small groups with the large variances. The 39 degrees of freedom of the tight group dominate MSW, so any comparison that involves group 2 or 3 is divided by a denominator too small by almost a factor of four. F comes out too large and the test rejects far more often than 5% when H0​ is true.

    (iii) Conservative. The reverse pairing. The large group is the variable one and pulls MSW up, so differences involving the small, tight groups are divided by a denominator that is far too large. The level is below nominal and power is lost; rejections that do occur are trustworthy, but real differences go undetected.

    (c) The recommendation. Use Welch's ANOVA for both (ii) and (iii), unconditionally. It estimates each group's variance separately and adjusts the degrees of freedom, exactly as Welch's t-test does for two groups, and it costs almost nothing when the variances turn out to be equal.

    Testing for equal variances first and choosing the main test on the result is a two-stage procedure whose overall error rate nobody computes. It is also weak precisely where it is needed: with n=5 in two of the groups, Levene's test has little power even against a nine-fold variance ratio, so a non-rejection would say almost nothing. The group sizes are known before any data are collected, and unequal sizes are reason enough.

  4. 4.Computation

    Four diets are compared with n=6 animals each. The mean weight gains are 30, 33, 37, 40, and the one-way ANOVA gives MSW=24 on 20 degrees of freedom with a significant F. Use q0.05,4,20​=3.958, t0.025,20​=2.086, and — for six comparisons at familywise 0.05 — the Bonferroni critical value t0.05/12,20​=2.927.

    1. (a)Compute Tukey's HSD and list every pair declared different at familywise α=0.05. Which comparisons come closest to the threshold without crossing it, and what may be said about those pairs?
    2. (b)Compute the Bonferroni margin for a pairwise difference, and explain — without consulting any table — why it had to come out larger than the HSD.
    3. (c)Compute the margin an uncorrected pairwise t-test would use. Which additional pairs would it declare different, and what is the approximate familywise error rate of that procedure if all four diets were in fact identical?

    Solution

    (a) Tukey. With equal group sizes,

    HSD=q0.05,4,20​nMSW​​=3.958624​​=3.958×2=7.916.

    The six pairwise differences are ∣30−33∣=3, ∣30−37∣=7, ∣30−40∣=10, ∣33−37∣=4, ∣33−40∣=7 and ∣37−40∣=3. Only 10 exceeds 7.916: diets 1 and 4 differ. No other pair can be separated.

    The closest calls are (1,3) and (2,4), both at 7, under the threshold by less than one unit. What may be said about them is only that the data do not separate them at familywise 5% — not that those diets are equal. Failure to reject is not evidence of equality, and with n=6 the procedure has limited power.

    (b) Bonferroni. Six comparisons, each two-sided at 0.05/6, so each tail gets 0.05/12. The margin is

    t0.05/12,20​MSW(n1​+n1​)​=2.92724⋅62​​=2.9278​=2.927×22​≈2.927×2.828≈8.28.

    That exceeds 7.916, and it had to. Bonferroni bounds the familywise rate by the union bound, which adds up the six comparisonwise rates as if the comparisons were unrelated; but they share the same four group means and the same MSW, so the bound is slack. Tukey's HSD instead uses the exact distribution of the most extreme comparison — the studentised range — and achieves α rather than staying under it. A threshold that only bounds the rate must be at least as strict as one that attains it. Here the two procedures reach the same conclusions (10>8.28, nothing else does), but Bonferroni has less room to spare.

    (c) Uncorrected. The margin for a single two-sided t-test at 5% is

    t0.025,20​8​=2.086×22​≈2.086×2.828≈5.90.

    Now 7, 10 and 7 all exceed it: (1,3) and (2,4) would be declared different in addition to (1,4) — two extra claims, bought by abandoning the familywise guarantee.

    Treating the six comparisons as independent, the probability of at least one false rejection when all four diets are identical is about

    1−(0.95)6=1−0.7351≈0.265,

    using 0.952=0.9025, 0.953=0.8574 and 0.956=0.85742≈0.7351. Roughly one experiment in four would report a spurious difference somewhere, which is the error rate the F-test was built to avoid.

  5. 5.Critique

    Reaction times are compared across three conditions. Condition 1 has 36 observations, obtained by testing 12 volunteers three times each; conditions 2 and 3 have 6 observations each, from six further volunteers apiece. The sample standard deviations are 3, 12 and 12. The analyst's report reads:

    Step 1. Levene's test of equal variances gives p=0.09, so the variances do not differ significantly and the equal-variance assumption holds.

    Step 2. In any case the F-test is robust to unequal variances, so pooling the three groups into MSW is safe.

    Step 3. A histogram of all 48 reaction times is strongly right-skewed. Normality therefore fails, and since normality is the most important of the three assumptions, the F-test cannot be trusted until the data are transformed.

    Step 4. Independence was verified by plotting the residuals xij​−xˉi​ against condition and seeing no pattern.

    Every one of the four steps contains an error.

    1. (a)For each step, state precisely what is wrong and name the principle it violates.
    2. (b)Compute MSW for this design. For a comparison between conditions 2 and 3, compare the pooled standard error MSW(1/6+1/6)​ with the standard error built from those two groups' own variance, and say what the discrepancy does to any t or F involving them.
    3. (c)Write the two or three sentences the report should have contained instead.

    Solution

    (a) The four errors.

    Step 1 mistakes non-rejection for confirmation, and uses a gatekeeper. A p-value of 0.09 does not establish equal variances; with only 6 observations in two of the three groups, Levene's test has little power, and the observed variance ratio 144/9=16 is four times the informal factor-of-four limit. Worse, deciding the main analysis on the outcome of a preliminary variance test makes the whole thing a two-stage procedure whose error rate is not the nominal one. Even a convincing Levene verdict would not license pooling here.

    Step 2 drops the condition on robustness. The F-test is robust to unequal variances when the group sizes are equal. These are 36,6,6, and the pairing is the dangerous one — the small groups carry the large variances — which inflates F and makes the test reject far too often.

    Step 3 checks the wrong quantity and ranks the assumptions backwards. The assumption is that the errors are normal, which is a statement about the residuals xij​−xˉi​, not about the pooled raw data; pooled data from groups with different means is expected to look irregular. And normality is the least important of the three assumptions, because the F statistic is built from group means that the central limit theorem is already normalising — the most important is independence. (A log transformation may well be sensible for reaction times, but not for the reason given, and not as the first priority.)

    Step 4 treats independence as something the data can certify. Independence is a property of how the data were collected and cannot be checked from the numbers; a residual plot with no pattern is fully consistent with strong dependence. And here the design tells us it fails: condition 1's 36 observations are 12 volunteers measured three times each. Repeated measurements on one person are correlated, so those 36 numbers carry something nearer 12 independent pieces of information, and every degree-of-freedom count in the analysis is wrong. This needs a different model — one with volunteer as a random effect — not a correction.

    (b) How far off the pooled denominator is. With N−k=48−3=45,

    MSW=4535⋅9+5⋅144+5⋅144​=45315+720+720​=451755​=39.

    For conditions 2 versus 3 the pooled standard error is 39(1/6+1/6)​=13​≈3.6. Using those two groups' own variance, 144, it is 144(1/6+1/6)​=48​=43​≈6.9. The pooled figure is too small by a factor of 48/13​≈1.9, so any t statistic between conditions 2 and 3 is inflated by about 1.9 and any F, being a squared quantity, by about 48/13≈3.7. A difference that is genuinely two standard errors out is reported as nearly four.

    Note this calculation still takes condition 1's 35 within-group degrees of freedom at face value, which Step 4 shows is itself unjustified.

    (c) What the report should say. “The group sizes are very unequal and the variance ratio is 16, with the small groups the more variable, so the pooled F-test is not valid; Welch's ANOVA is used instead. Condition 1 consists of three repeated measurements on each of 12 volunteers, so the analysis models volunteer as a random effect rather than treating the 36 values as independent. Normality was assessed on the residuals, not the raw times; it is the least critical assumption, and a log scale was considered on substantive grounds.”

  6. 6.Proof

    Work in the one-way model, under which the group means Xˉi​ are independent with Xˉi​∼N(μi​,σ2/ni​). A contrast is L=∑i​ci​μi​ with ∑i​ci​=0, estimated by L^=∑i​ci​Xˉi​.

    1. (a)Prove that E(L^)=L and Var(L^)=σ2∑i​ci2​/ni​, stating exactly where independence is used. Deduce the standard error MSW∑i​ci2​/ni​​, and check that for the pairwise contrast (1,−1,0,…,0) it reduces to the pooled two-sample standard error.
    2. (b)Prove that ∑i​ci​μi​ is unchanged when the same constant δ is added to every μi​ if and only if ∑i​ci​=0, and explain in one sentence why this property is what makes a contrast a comparison rather than a level.
    3. (c)Three fertilisers give plot-yield means 8, 11 and 20 with n=4 each and MSW=6 on 9 degrees of freedom. Test whether fertiliser 3 differs from the average of the other two: first as a planned contrast using t0.025,9​=2.262, then as an unplanned one using Scheffé's critical value with F0.05,2,9​=4.256. Say when each critical value is the legitimate one.

    Solution

    (a) Mean and variance of L^. Expectation is linear, so E(L^)=∑i​ci​E(Xˉi​)=∑i​ci​μi​=L; no independence is needed for this.

    For the variance, expand the linear combination:

    Var(i∑​ci​Xˉi​)=i∑​ci2​Var(Xˉi​)+2i<i′∑​ci​ci′​Cov(Xˉi​,Xˉi′​).

    The covariances vanish because different groups consist of disjoint sets of independent observations, so the group means are independent — this is the one place independence enters. What remains is ∑i​ci2​σ2/ni​. ■

    By the theorem on expected mean squares, MSW is unbiased for σ2 whether or not H0​ holds, so replacing σ2 by MSW gives the standard error MSW∑i​ci2​/ni​​. For c=(1,−1,0,…,0) the sum is 1/n1​+1/n2​ and the standard error is MSW(1/n1​+1/n2​)​=Sp​1/n1​+1/n2​​, since MSW is precisely the pooled variance — the two-sample formula recovered. ✓

    (b) Invariance under a common shift. Adding δ to every mean,

    i∑​ci​(μi​+δ)=i∑​ci​μi​+δi∑​ci​.

    If ∑i​ci​=0 the second term vanishes for every δ. Conversely, if the value is unchanged for some δ=0, then δ∑i​ci​=0 forces ∑i​ci​=0. ■

    A comparison is a statement about differences between means, and differences are exactly the quantities that survive a change of origin; a combination with ∑ci​=0 changes when every group is shifted equally, so it measures a level, which depends on where zero is.

    (c) The fertiliser contrast. “Fertiliser 3 versus the average of 1 and 2” is c=(−21​,−21​,1), which sums to zero ✓. The estimate is

    L^=−21​(8)−21​(11)+20=−219​+20=221​.

    For the standard error, ∑i​ci2​/ni​=(41​+41​+1)/4=23​⋅41​=83​, so

    SE=6⋅83​​=49​​=23​,t=3/221/2​=7.

    Planned: against t0.025,9​=2.262, 7 is far into the rejection region. Unplanned: Scheffé's critical value is (k−1)F0.05,2,9​​=2×4.256​=8.512​≈2.92 (since 2.922=8.53), and 7>2.92 as well.

    The t critical value is legitimate only if the contrast was fixed before the data were seen. If it was chosen after noticing that fertiliser 3 stood out, it is one of infinitely many contrasts that could have been picked, and only Scheffé's value — which bounds the maximum over all of them simultaneously — controls the error rate. Here the conclusion holds under either standard, so it does not matter which story is true; it often does.

  7. 7.Computation

    A two-way design has factor A (two coatings) and factor B (three curing temperatures), with n=5 specimens per cell. The cell means, listed at B1​,B2​,B3​, are

    A1​: 6, 9, 12. A2​: 10, 11, 12.

    The within-cell sum of squares is SSE=96. Use F0.05,1,24​=4.260 and F0.05,2,24​=3.403.

    1. (a)Compute the row means xˉi⋅​, the column means xˉ⋅j​ and the grand mean, and hence SSA and SSB.
    2. (b)For each cell compute the departure from additivity xˉij​−xˉi⋅​−xˉ⋅j​+xˉ. Check that the departures sum to zero along every row and every column, and compute SSAB.
    3. (c)Build the full ANOVA table, check that the degrees of freedom sum to abn−1, test the three effects at α=0.05, and decide whether the main effects may be interpreted. If they may, state each in words.

    Solution

    (a) Marginal means and the main-effect sums of squares. Row means: xˉ1⋅​=(6+9+12)/3=9 and xˉ2⋅​=(10+11+12)/3=11. Column means: xˉ⋅1​=(6+10)/2=8, xˉ⋅2​=10, xˉ⋅3​=12. Grand mean xˉ=(9+11)/2=10, which also equals (8+10+12)/3 ✓.

    Each row mean averages bn=15 observations and each column mean an=10, so

    SSA=bni∑​(xˉi⋅​−xˉ)2=15[(−1)2+12]=30,SSB=anj∑​(xˉ⋅j​−xˉ)2=10[(−2)2+0+22]=80.

    (b) Departures from additivity. Additivity predicts cell (i,j) to be xˉi⋅​+xˉ⋅j​−xˉ. Row 1 predictions: 9+8−10=7, 9+10−10=9, 9+12−10=11; the actual means are 6,9,12, so the departures are −1,0,+1. Row 2 predictions: 11+8−10=9, 11, 13; actual 10,11,12, departures +1,0,−1.

    Row sums: −1+0+1=0 and 1+0−1=0 ✓. Column sums: −1+1, 0+0, 1−1, all 0 ✓. This is forced by the sum-to-zero constraints on the interaction effects, and it is why the interaction has only (a−1)(b−1)=2 degrees of freedom — two of the six departures determine the rest.

    Each departure is shared by n=5 observations, so

    SSAB=ni,j∑​(departure)2=5[1+0+1+1+0+1]=20.

    (c) The table and the tests. Degrees of freedom: A has a−1=1; B has b−1=2; AB has (a−1)(b−1)=2; error has ab(n−1)=6×4=24. Sum 1+2+2+24=29=abn−1=30−1 ✓.

    Mean squares: MSA=30, MSB=40, MSAB=10, MSE=96/24=4. Every effect is tested over MSE:

    FA​=430​=7.5,FB​=440​=10,FAB​=410​=2.5.

    Against the critical values: FA​=7.5>4.260, significant; FB​=10>3.403, significant; FAB​=2.5<3.403, not significant. By the two-way decomposition the total is SST=30+80+20+96=226 on 29 degrees of freedom.

    The interaction is not significant, so the main effects may be interpreted as averages over the other factor. Coating A2​ produces a response 2 units higher than A1​ on average (11 against 9). Each step up in curing temperature raises the response by 2 units on average (8,10,12).

    One caveat belongs in the report. A non-significant interaction is not a proof of additivity: in the sample, temperature raised A1​ by 6 across the range but A2​ by only 2, and with MSE=4 that difference is simply not distinguishable from noise at F=2.5. The main effects are the right summary, but “no interaction” should be read as “none detected”.

  8. 8.Sketch

    Three 2×2 designs have factor A at levels A1​,A2​ and factor B at levels B1​,B2​, with n=3 observations per cell. The cell means, listed at B1​,B2​, are

    (i) A1​: 4, 8; A2​: 6, 10. (ii) A1​: 4, 8; A2​: 8, 4. (iii) A1​: 4, 4; A2​: 4, 10.

    1. (a)Draw the interaction plot for each design — level of B on the horizontal axis, one line per level of A — and describe the geometry of the two lines.
    2. (b)Compute SSA, SSB and SSAB for each design, and confirm in each case that they add up to n∑i,j​(xˉij​−xˉ)2, the total between-cell sum of squares.
    3. (c)For each design, say which sums of squares the picture predicted would vanish, and why. In design (ii), explain what the statement “B has no effect” gets wrong and give the simple effects of B instead.

    Solution

    (a) The three plots. Each plot has B1​ and B2​ as two positions on the horizontal axis, cell mean on the vertical axis, and two line segments: the A1​ segment joins (B1​,xˉ11​) to (B2​,xˉ12​) and the A2​ segment joins (B1​,xˉ21​) to (B2​,xˉ22​). Label the segments and use a common vertical scale from 0 to 12 so the three pictures can be compared.

    (i) A1​ runs from 4 up to 8; A2​ runs from 6 up to 10. The two segments are parallel, both rising by 4, with A2​ a constant 2 above A1​. Draw the vertical gap at both ends and mark it 2 each time — that equal gap is additivity.

    (ii) A1​ runs from 4 up to 8; A2​ runs from 8 down to 4. The segments form an X, crossing at the midpoint, height 6. One slope is +4 and the other −4; mark both.

    (iii) A1​ is flat at 4; A2​ rises from 4 to 10. The segments start together at B1​ and diverge, the gap growing from 0 to 6. Mark the shared starting point.

    (b) The sums of squares. Throughout, a=b=2, n=3, so each row and column mean averages 6 observations and SSA=6∑i​(xˉi⋅​−xˉ)2, SSB=6∑j​(xˉ⋅j​−xˉ)2, and SSAB=3∑i,j​(departure)2 with departure xˉij​−xˉi⋅​−xˉ⋅j​+xˉ.

    (i) Row means 6,8; column means 5,9; grand mean 7. SSA=6[1+1]=12; SSB=6[4+4]=48. Predicted cells: 6+5−7=4, 6+9−7=8, 8+5−7=6, 8+9−7=10 — every cell is exactly predicted, so SSAB=0. Between-cell total: 3[(4−7)2+(8−7)2+(6−7)2+(10−7)2]=3[9+1+1+9]=60=12+48+0 ✓.

    (ii) Row means 6,6; column means 6,6; grand mean 6. SSA=0 and SSB=0. Every cell is predicted to be 6, so the departures are −2,+2,+2,−2 and SSAB=3[4+4+4+4]=48. Between-cell total: 3[4+4+4+4]=48=0+0+48 ✓.

    (iii) Row means 4,7; column means 4,7; grand mean 211​. SSA=6[49​+49​]=27 and likewise SSB=27. Predicted cells: 4+4−211​=25​, 4+7−211​=211​, 7+4−211​=211​, 7+7−211​=217​; actual 4,4,4,10; departures +23​,−23​,−23​,+23​. So SSAB=3⋅4⋅49​=27. Between-cell total: 3[49​+49​+49​+481​]=3⋅27=81=27+27+27 ✓.

    (c) Reading the pictures. (i) Parallel lines are the picture of additivity, so SSAB had to vanish: the interaction is exactly the departure from parallel, and there is none. Both main effects are visible — the lines rise (a B effect) and are separated (an A effect).

    (ii) The X is symmetric: the A1​ and A2​ segments have the same average height (6), so the row means agree and SSA=0; and the heights at B1​ and B2​ average to the same 6, so the column means agree and SSB=0. Everything is interaction. Nothing vanishes in (iii): the lines are not parallel, their average heights differ, and the average heights at the two B levels differ.

    In (ii), “B has no effect” reads SSB=0 as if B were inert. But SSB measures the effect of B averaged over the levels of A, and here it is being averaged over a sign change. The simple effects are: within A1​, moving from B1​ to B2​ raises the response by 8−4=+4; within A2​, it lowers it by 4−8=−4. Factor B moves the response by 4 units at every level of A — in opposite directions. When the interaction is present the correct report is these simple effects or the cell means themselves, never the main effect.

  9. 9.Computation

    A testing authority draws k=12 laboratories at random from the national register and sends each of them n=6 portions of the same reference material. The one-way ANOVA of the measured concentrations gives MSB=75 and MSW=15. Use F0.05,11,60​=1.952.

    1. (a)Explain why this is a random-effects situation, write down the model, and state the null hypothesis in terms of its parameters.
    2. (b)Estimate the between-laboratory variance σA2​, the within-laboratory variance σ2, the variance of a single measurement, and the intraclass correlation. Interpret the last two in a sentence each.
    3. (c)Compute F and test at α=0.05. Say what a rejection means here, and how that differs from what the same numbers would mean if these twelve laboratories were the only ones of interest.
    4. (d)A repeat exercise with twelve new laboratories gives MSB=12 and MSW=15. Estimate σA2​, explain the result, and say what it does and does not indicate.

    Solution

    (a) Why random. The twelve laboratories are of no interest in themselves; they were drawn from a register so that the conclusion can be about the population of laboratories, and the question is how much laboratories vary. That is the random-effects model,

    Xij​=μ+Ai​+εij​,Ai​∼iidN(0,σA2​),εij​∼iidN(0,σ2),

    with the Ai​ independent of the εij​. The null hypothesis is H0​:σA2​=0 — laboratories do not vary at all — rather than a statement about twelve particular means.

    (b) The variance components. By the expected mean squares under random effects, E(MSW)=σ2 and E(MSB)=σ2+nσA2​. Equating mean squares to their expectations,

    σ^2=MSW=15,σ^A2​=nMSB−MSW​=675−15​=10.

    A single measurement has variance Var(Xij​)=Var(Ai​)+Var(εij​)=σA2​+σ2 by independence, estimated by 10+15=25: a measurement sent to a randomly chosen laboratory has standard deviation about 5 concentration units, of which laboratory choice and within-laboratory noise are both substantial parts. The intraclass correlation is

    σ^A2​+σ^2σ^A2​​=2510​=0.4,

    so 40% of the variance of a single measurement is between laboratories, and two portions measured by the same laboratory have correlation 0.4.

    (c) The test and what it means. F=MSB/MSW=75/15=5 on k−1=11 and k(n−1)=60 degrees of freedom. Since 5>1.952, reject H0​.

    The rejection says σA2​>0: laboratories in the population genuinely differ in what they report for the same material. It is a statement about all laboratories on the register, and the natural follow-up is the estimate σ^A2​=10 and the intraclass correlation. Had the twelve been fixed — the only twelve the authority uses — the same F=5 would say that these particular laboratories do not all have the same mean, and the follow-up would be a post-hoc procedure asking which ones differ. The arithmetic is identical; the estimand is not.

    (d) A negative estimate. Now σ^A2​=(12−15)/6=−21​. A variance cannot be negative, but the estimate is not a computational error: the method of moments returns a negative value whenever MSB<MSW, and under H0​ that happens roughly half the time, since both mean squares then estimate the same σ2. The usual remedy is to truncate at zero and report σ^A2​=0, with the caveat that truncation biases the estimator upward.

    Here F=12/15=0.8<1.952, so H0​ is not rejected. What this indicates: the data provide no evidence of between-laboratory variance. What it does not indicate: that laboratories are identical. A small F is not evidence for the null beyond the non-rejection, and with n=6 per laboratory the estimate of σA2​ is imprecise.

  10. 10.Proof

    Work in the balanced random-effects model Xij​=μ+Ai​+εij​ for i=1,…,k and j=1,…,n, with Ai​∼iidN(0,σA2​), εij​∼iidN(0,σ2), and every Ai​ independent of every εij​. You may quote E(MSW)=σ2 and E(MSB)=σ2+nσA2​.

    1. (a)Prove that two observations in the same group have covariance σA2​ and correlation ρ=σA2​/(σA2​+σ2), and that observations in different groups are independent. Deduce that ρ≥0 always, and identify the case ρ=0.
    2. (b)Prove that the grand mean satisfies Var(Xˉ)=kσA2​​+knσ2​. Find its limit as n→∞ with k fixed, and explain what this says about choosing between more groups and more observations per group when the aim is to estimate μ.
    3. (c)Prove that σ^A2​=(MSB−MSW)/n is unbiased for σA2​, and then that the truncated estimator max(σ^A2​,0) has expectation strictly greater than σA2​ whenever P(MSB<MSW)>0. Why is that probability certainly positive under H0​?

    Solution

    (a) The covariance structure. Fix a group i and two distinct observations j=l in it. The constant μ contributes nothing to any covariance, so by bilinearity

    Cov(Xij​,Xil​)=Cov(Ai​+εij​,Ai​+εil​)=Var(Ai​)+Cov(Ai​,εil​)+Cov(εij​,Ai​)+Cov(εij​,εil​).

    The last three terms are zero: the A's are independent of the ε's, and distinct ε's are independent. So the covariance is σA2​ — the shared group effect is the only thing two group-mates have in common. For the variance, the same expansion with j=l gives Var(Xij​)=σA2​+σ2, and therefore

    ρ=Var(Xij​)Var(Xil​)​Cov(Xij​,Xil​)​=σA2​+σ2σA2​​.

    For observations in different groups i=i′, every one of the four terms in the expansion of Cov(Ai​+εij​,Ai′​+εi′l​) is zero: distinct A's are independent, A's and ε's are independent, and distinct ε's are independent. So the two observations are uncorrelated. They are moreover independent, because the whole vector (Xij​) is a linear function of the independent normal variables A1​,…,Ak​,ε11​,…,εkn​ and is therefore jointly normal, and for jointly normal variables zero correlation is independence. ■

    Since σA2​≥0 is a variance and the denominator is positive, ρ≥0: this model can never make group-mates negatively correlated. Equality ρ=0 holds exactly when σA2​=0, which is H0​ — under the null the group structure carries no information and the kn observations are simply i.i.d. N(μ,σ2).

    (b) Variance of the grand mean. Averaging the model over all kn observations,

    Xˉ=μ+k1​i=1∑k​Ai​+kn1​i,j∑​εij​.

    The two random sums are independent (one is built from the A's, the other from the ε's), so their variances add:

    Var(k1​i∑​Ai​)=k2kσA2​​=kσA2​​,Var(kn1​i,j∑​εij​)=(kn)2knσ2​=knσ2​,

    using independence within each sum. Hence Var(Xˉ)=σA2​/k+σ2/(kn). ■ (Equivalently: Xˉ is the average of the k i.i.d. group means, each with variance σA2​+σ2/n by the theorem on expected mean squares under random effects, and dividing by k gives the same thing.)

    As n→∞ with k fixed the second term vanishes and Var(Xˉ)→σA2​/k, which is not zero unless σA2​=0. More observations per group eliminate the measurement noise but leave the k draws of the group effect exactly as they were; the grand mean can never estimate μ more precisely than an average of k observations from N(μ,σA2​) does. If the aim is μ, precision comes from sampling more groups. With a fixed total of kn observations, the design that spreads them over many groups beats the one that concentrates them in a few — for instance k=100, n=2 gives σA2​/100+σ2/200, while k=2, n=100 gives σA2​/2+σ2/200.

    (c) Unbiasedness, and the cost of truncation. By the quoted expectations and linearity,

    E(σ^A2​)=nE(MSB)−E(MSW)​=nσ2+nσA2​−σ2​=σA2​.■

    Write T=σ^A2​ and T+=max(T,0). Then T+−T=max(−T,0)≥0 everywhere, and T+−T=−T>0 exactly on the event {T<0}={MSB<MSW}. A non-negative random variable that is strictly positive on an event of positive probability has strictly positive expectation, so if P(MSB<MSW)>0 then

    E(T+)−E(T)=E[(T+−T)]>0,i.e.E[max(σ^A2​,0)]>σA2​.■

    Under H0​ the ratio MSB/MSW has the Fk−1,k(n−1)​ distribution, which has positive density on all of (0,∞), so P(MSB/MSW<1) is strictly positive — in fact close to one half, since both mean squares are estimating the same σ2 and their ratio falls on either side of 1 with comparable probability. The consequence is uncomfortable: when the true between-group variance is exactly zero, the truncated estimator has strictly positive expectation. This is the awkwardness of the moment estimator that pushes practice toward likelihood-based estimates of variance components.

  11. 11.Critique

    Three training programmes are compared, n=10 trainees each, with score means xˉ1​=12, xˉ2​=10, xˉ3​=14 and MSW=10 on 27 degrees of freedom. An analyst fits the indicator model with programme 1 as reference and reports:

    Step 1. β^​2​=−2 and β^​3​=2, each with standard error 2​, so t=∓1.41. Against t0.025,27​=2.052 neither is significant.

    Step 2. The ANOVA F-test is just these two tests combined, so it cannot be significant either. The three programmes are equivalent.

    Step 3. Refitting with programme 2 as reference gives β^​3​=4 with t=2.83, which is significant. Since the two fits contradict each other, the coding is unreliable, and the first fit is the one reported.

    Use F0.05,2,27​=3.354 and q0.05,3,27​=3.51.

    1. (a)Verify the standard error and the t values in Step 1. Then identify the error in each of Steps 2 and 3, naming the principle each violates.
    2. (b)Carry out the model-comparison F-test from the numbers given and state the correct conclusion.
    3. (c)Explain why F rejects while neither coefficient in Step 1 is significant: which comparison does F see that the reference coding hides? Then decide, using Tukey's HSD, whether that comparison survives a familywise correction.

    Solution

    (a) Step 1 is correct; Steps 2 and 3 are not. Under indicator coding β^​i​=xˉi​−xˉ1​, a difference of two independent group means, so its variance is σ2(1/n1​+1/ni​) and, estimating σ2 by MSW,

    SE(β^​i​)=10(101​+101​)​=2​.t=2​∓2​=∓2​≈∓1.41.✓

    Step 2 misdescribes the F-test and then misreads a non-rejection. The F-test is a model comparison: it tests the single joint hypothesis β2​=β3​=0 by comparing SSE under the full model with SSE under the intercept-only model. It is not a combination of the two coefficient tests, which are two uncorrected comparisons against the reference — and neither of them tests whether programmes 2 and 3 differ from each other. A joint hypothesis can be rejected while every marginal one survives. Separately, “not significant” is not “equivalent”: failing to reject is not evidence of equality.

    Step 3 mistakes a reparameterisation for a contradiction. The coefficients are comparisons against whichever reference was chosen, so of course they change with the reference; what does not change is the set of fitted values, hence SSE, hence F. The two fits agree perfectly: under reference 2, β^​3​=xˉ3​−xˉ2​=14−10=4, which is exactly β^​3​−β^​2​=2−(−2)=4 from the first fit. Choosing which fit to report according to which looks significant is a selection, and it is exactly the uncorrected reference-level comparison the F-test exists to replace.

    (b) The F-test. The grand mean is (12+10+14)/3=12, so

    SSB=10[(12−12)2+(10−12)2+(14−12)2]=10[0+4+4]=80,SSW=27×10=270.

    By the decomposition of the total sum of squares, SST=350. The full model fits each group its own mean, so SSEfull​=SSW=270, while the intercept-only model has SSE=SST=350. The model-comparison statistic is

    F=270/27(350−270)/2​=1040​=4.0>3.354.

    Reject H0​ at 5%: the three programmes do not all have the same mean score. Step 2's conclusion is the opposite of the truth.

    (c) What F sees. Programme 1 happens to sit in the middle of the three means. Each coefficient in the reference-1 coding measures a gap of 2, which is 2​≈1.41 standard errors; but the gap between programmes 2 and 3 is 4, which is 22​≈2.83 standard errors, and no coefficient in that coding measures it. The F-test does not compare anything to a reference: SSB counts programme 2 and programme 3 as each 2 away from the grand mean on opposite sides, so the 4-unit spread between them is fully present in the numerator. That is why F rejects while both coefficients fail — the reference coding was looking at the two smallest of the three differences.

    Whether the 2-versus-3 comparison survives a familywise correction is a Tukey question. With equal group sizes,

    HSD=q0.05,3,27​nMSW​​=3.511010​​=3.51.

    The differences are ∣12−10∣=2, ∣12−14∣=2 and ∣10−14∣=4. Only 4>3.51: programmes 2 and 3 differ at familywise 5%, and neither can be separated from programme 1. So the t=2.83 in Step 3 was uncorrected, but the finding it pointed at is genuine. The correct report is: the programmes differ (F=4.0, p<0.05), and the difference the data can locate is between programmes 2 and 3.

  12. 12.Proof

    Consider k groups with ni​ observations xij​, group means xˉi​, grand mean xˉ and N=∑i​ni​. The indicator model with group 1 as reference is X=β0​+β2​D2​+⋯+βk​Dk​+ε. Prove the following from scratch. The only results you may quote are the decomposition SST=SSB+SSW and, in part (d), the proposition that with two groups F=t2.

    1. (a)Show that for any number m and any group i, ∑j​(xij​−m)2=∑j​(xij​−xˉi​)2+ni​(xˉi​−m)2. Deduce that the least-squares fit of the indicator model gives every observation in group i the fitted value xˉi​, and conclude SSEfull​=SSW.
    2. (b)Read off the least-squares coefficients β^​0​,β^​2​,…,β^​k​. Then show that if group r is used as the reference instead, the coefficients change but the fitted values, SSEfull​ and the F statistic do not.
    3. (c)Show that the intercept-only model has residual sum of squares SST, and hence that the model-comparison statistic SSEfull​/(N−k)(SST−SSEfull​)/(k−1)​ equals MSB/MSW.
    4. (d)For k=2, show that the t statistic for H0​:β2​=0 is the pooled two-sample t statistic, so that the coefficient test and the F-test coincide. Explain in one sentence why no such coincidence holds for k≥3.

    Solution

    (a) The one-group identity, and the fit. Insert and remove the group mean: xij​−m=(xij​−xˉi​)+(xˉi​−m). Squaring and summing over j,

    j∑​(xij​−m)2=j∑​(xij​−xˉi​)2+2(xˉi​−m)j∑​(xij​−xˉi​)+ni​(xˉi​−m)2.

    The middle sum is ∑j​xij​−ni​xˉi​=0 by the definition of xˉi​, which proves the identity. ■ Since the second term on the right is non-negative and zero only at m=xˉi​, the identity also says: over all m, the sum ∑j​(xij​−m)2 is uniquely minimised at m=xˉi​.

    Now the model. An observation in group 1 has every indicator zero, so its fitted value is β0​; an observation in group i≥2 has Di​=1 and the others zero, so its fitted value is β0​+βi​. Write m1​=β0​ and mi​=β0​+βi​ for the group levels. The map (β0​,β2​,…,βk​)↦(m1​,…,mk​) is a bijection of Rk — its inverse is β0​=m1​, βi​=mi​−m1​ — so minimising the residual sum of squares over the β's is the same as minimising

    i∑​j∑​(xij​−mi​)2

    over all (m1​,…,mk​) freely. The sum splits into k pieces, and piece i involves only mi​. By the identity, each piece is minimised uniquely at mi​=xˉi​, so the whole sum is minimised there. The fitted value of every observation in group i is xˉi​, and the minimum value is

    SSEfull​=i∑​j∑​(xij​−xˉi​)2=SSW.■

    (b) The coefficients, and changing the reference. From the inverse map, β^​0​=m^1​=xˉ1​ and β^​i​=m^i​−m^1​=xˉi​−xˉ1​ for i=2,…,k: the intercept is the reference group's mean, and each slope is a difference from it.

    With group r as reference, the fitted value in group r is β0​ and in group i=r it is β0​+βi​; the correspondence β0​=mr​, βi​=mi​−mr​ is again a bijection onto the same set of level vectors (m1​,…,mk​). The minimisation over the levels is therefore the same problem with the same unique solution m^i​=xˉi​. So the fitted values are unchanged, the residuals are unchanged, SSEfull​=SSW is unchanged, and F — which is built from SST, SSEfull​ and the degrees of freedom, none of which mention the coding — is unchanged. What does change is the coefficients: β^​0​=xˉr​ and β^​i​=xˉi​−xˉr​, a different set of comparisons describing the same fit. ■

    (c) The reduced model. The intercept-only model gives every observation the fitted value m. Apply the identity of (a) with the entire sample treated as one group of size N and mean xˉ:

    i,j∑​(xij​−m)2=i,j∑​(xij​−xˉ)2+N(xˉ−m)2 ≥ SST,

    with equality at m=xˉ. So the least-squares intercept is the grand mean and SSEreduced​=SST. Then, by the quoted decomposition, SST−SSEfull​=SST−SSW=SSB, and

    SSEfull​/(N−k)(SST−SSEfull​)/(k−1)​=SSW/(N−k)SSB/(k−1)​=MSWMSB​.■

    The degrees of freedom are the right ones: the full model has k parameters, leaving N−k residual degrees of freedom, and the reduced model has 1, so the comparison spends k−1.

    (d) Two groups. For k=2 the one coefficient is β^​2​=Xˉ2​−Xˉ1​. Under the model the two group means are independent with variances σ2/n1​ and σ2/n2​, so Var(β^​2​)=σ2(1/n1​+1/n2​). The regression estimate of σ2 is the residual mean square SSEfull​/(N−2)=SSW/(N−2), which by (a) is the pooled variance Sp2​. Hence

    t=SE(β^​2​)β^​2​​=Sp​1/n1​+1/n2​​Xˉ2​−Xˉ1​​,

    the pooled two-sample t statistic, and by the proposition that with two groups F is the square of t, the coefficient test and the model-comparison F-test reject on exactly the same data, with matching critical values Fα,1,ν​=tα/2,ν2​. ■

    For k≥3 there are k−1 coefficients, each testing one difference from the reference at an uncorrected level, whereas F tests the single joint hypothesis that all k−1 vanish — and a joint hypothesis is neither the conjunction of separately tested marginal ones nor sensitive to which group was chosen as the reference, as the previous problem shows in numbers.

← Back to the question sheet

CalcPath·Free university mathematics

SubjectsProblem setsProgressFeedbackAbout