Statistics 2nd ed

variance-partitioning

Mixed (Split-Plot) ANOVA

mixed anova layout
mixed anova mean profile
partitioning variance
f distribution
split-plot interaction

Goal. Test a between-subjects factor (Group: Drug vs. Placebo) and a within-subjects factor (Time: Weeks 1–3), plus their interaction, on exam scores.

Design & Experiment

  • Between-subjects factor: Group = {Drug, Placebo}
  • Within-subjects factor: Time = {Week 1, Week 2, Week 3}
  • Balanced: 8 participants per group (\(s_g=8\)), 3 repeated measures per participant (\(k=3\)).

Participants are randomly assigned to Drug or Placebo. The same exam is given at Week 1, Week 2, and Week 3.

Figure 1: Mixed design layout (Drug vs Placebo × Weeks 1–3).


Data

Group: Drug (8 participants × 3 weeks)

SubjectW1W2W3Row sumRow mean
D170747822274.00
D269737721973.00
D371757922575.00
D472768022876.00
D568727621672.00
D670747822274.00
D773778123177.00
D871768022775.67
Column sums564597629Group sum = 1790Group mean \( \bar X_{\text{Drug}} = 1790/24 = 74.5833 \)

Group: Placebo (8 participants × 3 weeks)

SubjectW1W2W3Row sumRow mean
P170717221371.00
P269707121070.00
P371727321672.00
P472737421973.00
P568697020769.00
P670717221371.00
P769707121070.00
P871727321672.00
Column sums560568576Group sum = 1704Group mean \( \bar X_{\text{Plac}} = 1704/24 = 71.0000 \)

Totals. Grand sum = 1790 + 1704 = 3494, total observations \(N = 16\times3 = 48\), grand mean \( \bar X = 3494/48 = 72.7917\).

Figure 2: Mean profiles over weeks (Drug rises sharply; Placebo ~ flat).


Step 1 — Marginal Means

By Time (across both groups; 16 participants each week): \[ \bar X_{\text{W1}}=\tfrac{1124}{16}=70.2500,\qquad \bar X_{\text{W2}}=\tfrac{1165}{16}=72.8125,\qquad \bar X_{\text{W3}}=\tfrac{1205}{16}=75.3125, \] where column sums are \(1124, 1165, 1205\).

By Group (across all weeks): \[ \bar X_{\text{Drug}}=74.5833,\qquad \bar X_{\text{Placebo}}=71.0000. \]


Step 2 — Sums of Squares (SS)

Decompose total variability into Between-Subjects and Within-Subjects parts.

2A. Total

\[ SS_{\text{total}}=\sum (X_{igt}-\bar X)^2=\mathbf{527.9167}. \]

2B. Between-Subjects

Let each subject’s mean be \(\bar X_{i\cdot}\). Then \[ SS_{\text{BS-total}}=k\sum_{i=1}^{16}(\bar X_{i\cdot}-\bar X)^2=\mathbf{247.2500}. \] Split into Group and Subjects-within-Group: \[ SS_{\text{Group}}=k\sum_{g} n_g(\bar X_{g\cdot\cdot}-\bar X)^2=\mathbf{154.0833}, \] \[ SS_{\text{Subj}(g)}=k\sum_{i\in g}(\bar X_{i\cdot}-\bar X_{g\cdot\cdot})^2=\mathbf{93.1667}. \]

2C. Within-Subjects

\(SS_{\text{WS-total}}=SS_{\text{total}}-SS_{\text{BS-total}}=\mathbf{280.6667}.\)

Decompose into Time, Group×Time, and residual Error: \[ SS_{\text{Time}}=s\sum_{t}(\bar X_{\cdot\cdot t}-\bar X)^2=\mathbf{205.0417}, \] \[ SS_{\text{Group}\times\text{Time}} =\sum_{g,t} n_g\Big(\bar X_{g\cdot t}-\bar X_{g\cdot\cdot}-\bar X_{\cdot\cdot t}+\bar X\Big)^2 =\mathbf{75.0417}, \] \[ SS_{\text{Error(WS)}}=SS_{\text{WS-total}}-SS_{\text{Time}}-SS_{\text{G}\times\text{T}} =\mathbf{0.5833}. \]

Figure 3: Partitioning diagram (Between: Group + Subj(Group); Within: Time + G×T + Error).


Step 3 — Degrees of Freedom (df) & Mean Squares (MS)

\[ \begin{aligned} &df_{\text{Group}}=g-1=1,\qquad df_{\text{Subj}(g)}=N_s-g=16-2=14,\\ &df_{\text{Time}}=k-1=2,\qquad df_{\text{G}\times\text{T}}=(g-1)(k-1)=2,\\ &df_{\text{Error(WS)}}=(N_s-g)(k-1)=(16-2)\times2=28,\\ &df_{\text{Total}}=Nk-1=48-1=47. \end{aligned} \]

\[ \begin{aligned} &MS_{\text{Group}}=\frac{SS_{\text{Group}}}{df_{\text{Group}}}= \frac{154.0833}{1}= \mathbf{154.0833},\qquad MS_{\text{Subj}(g)}=\frac{93.1667}{14}= \mathbf{6.6548},\\ &MS_{\text{Time}}=\frac{205.0417}{2}= \mathbf{102.5208},\qquad MS_{\text{G}\times\text{T}}=\frac{75.0417}{2}= \mathbf{37.5208},\\ &MS_{\text{Error(WS)}}=\frac{0.5833}{28}= \mathbf{0.02083}. \end{aligned} \]


Step 4 — F Tests & p-values

Between-subjects test: \[ F_{\text{Group}}=\frac{MS_{\text{Group}}}{MS_{\text{Subj}(g)}}=\frac{154.0833}{6.6548}= \mathbf{23.1538}, \quad df=(1,14),\quad p\approx \mathbf{0.00028}. \]

Within-subjects tests: \[ F_{\text{Time}}=\frac{MS_{\text{Time}}}{MS_{\text{Error(WS)}}} =\frac{102.5208}{0.02083}= \mathbf{4921.0},\quad df=(2,28),\quad p\ll 10^{-20}. \] \[ F_{\text{G}\times\text{T}}=\frac{MS_{\text{G}\times\text{T}}}{MS_{\text{Error(WS)}}} =\frac{37.5208}{0.02083}= \mathbf{1801.0},\quad df=(2,28),\quad p\ll 10^{-20}. \]

Figure 4: F distributions with observed statistics marked.


Mixed ANOVA Summary Table

SourceSSdfMSFp
Between: Group154.08331154.083323.15380.00028
Between: Subjects within Group93.1667146.6548
Within: Time205.04172102.52084921.0< 1e-20
Within: Group × Time75.0417237.52081801.0< 1e-20
Within: Error (Subj×Time within Group)0.5833280.02083
Total527.916747

Interpretation

Group: Drug > Placebo overall (significant between-subjects effect).
Time: Scores increase across weeks (strong within-subjects effect).
Group × Time: The Drug group improves sharply week-to-week while the Placebo group changes little (significant interaction).

Figure 5: Interaction plot showing non-parallel lines (Drug rising; Placebo flat).

Assumptions (checklist)

  • Independence between subjects; correct grouping.
  • Approximate normality within each Group×Time cell.
  • Homogeneity of variance across groups (between-subjects).
  • Sphericity for the within-subject factor Time (apply Greenhouse–Geisser/Huynh–Feldt corrections if violated).

Note: The residual within-subject error is intentionally small in this teaching dataset, so the Time and G×T F values are very large. Real data typically have larger residual variability.

Practice self-test quiz

In the space below, please find practice problems and self-test quizzes. For full access, please signup free.

One-Way ANOVA

anova boxplot
anova means sem
anova partition variance
anova f distribution

Goal. Test whether three teaching methods lead to different average exam scores.

Design & Experiment

Twenty-four students are randomly assigned to one of three methods (n = 8 per group):

  • Group A: Active discussion
  • Group B: Structured lecture
  • Group C: Self-study

After a 2-week module, everyone takes the same 100-point exam.


Data

Group AGroup BGroup C
727865
688270
758066
707768
697967
738169
718364
747671

Figure 1: Boxplots of scores by group.

Group sizes: \(n_A=n_B=n_C=8\). Total \(N=24\).


Step 1 — Sums & Means

\(\displaystyle \begin{aligned} \text{Sums:}&\quad \sum A=572,\;\; \sum B=636,\;\; \sum C=540.\\[4pt] \text{Means:}&\quad \bar A=\tfrac{572}{8}=71.5,\;\; \bar B=\tfrac{636}{8}=79.5,\;\; \bar C=\tfrac{540}{8}=67.5.\\[4pt] \text{Grand mean:}&\quad \bar X=\tfrac{572+636+540}{24}=72.8333\ldots \end{aligned} \)


Step 2 — Within-Group Variability (sample variances)

For each group, compute \( s_g^2=\dfrac{\sum(x-\bar x_g)^2}{n_g-1} \).

  • \(s_A^2 = 6.0\)
  • \(s_B^2 = 6.0\)
  • \(s_C^2 = 6.0\)

Corresponding sums of squares within each group: \(\displaystyle SS_A=\sum(x-\bar A)^2=42,\; SS_B=42,\; SS_C=42\Rightarrow SS_{\text{within}}=42+42+42=126.0. \)

Figure 2: Group means with SEM error bars.


Step 3 — Between-Groups Variability

\(\displaystyle SS_{\text{between}}=\sum_{g} n_g(\bar x_g-\bar X)^2 =8(71.5-72.8333)^2+8(79.5-72.8333)^2+8(67.5-72.8333)^2 =597.3333\ldots \)

Total sum of squares: \(\displaystyle SS_{\text{total}}=\sum (x-\bar X)^2 = SS_{\text{between}}+SS_{\text{within}} =597.3333\ldots+126.0=723.3333\ldots \)

Figure 3: Partitioning variance (\(SS_{\text{total}}=SS_{\text{between}}+SS_{\text{within}}\)).


Degrees of Freedom & Mean Squares

\(\displaystyle df_{\text{between}}=k-1=3-1=2,\qquad df_{\text{within}}=N-k=24-3=21,\qquad df_{\text{total}}=N-1=23. \)

\(\displaystyle MS_{\text{between}}=\frac{SS_{\text{between}}}{df_{\text{between}}} =\frac{597.3333}{2}=298.6667,\qquad MS_{\text{within}}=\frac{SS_{\text{within}}}{df_{\text{within}}} =\frac{126.0}{21}=6.0. \)


Test Statistic & p-value

\(\displaystyle F=\frac{MS_{\text{between}}}{MS_{\text{within}}} =\frac{298.6667}{6.0}=49.7778. \)

With \(df_1=2\), \(df_2=21\), the (right-tail) p-value is \(p\approx 1.07\times10^{-8}\) (i.e., \(p<0.00000002\)).

Figure 4: F distribution curve with right-tail decision region.


ANOVA Summary Table

SourceSSdfMSFp
Between groups597.33332298.666749.7778< 0.00000002
Within (error)126.0000216.0000
Total723.333323

Conclusion

There is a statistically significant difference among the three methods’ mean scores (\(F(2,21)=49.78,\; p\ll .001\)). A post-hoc comparison (e.g., Tukey HSD) would identify which pairs differ.

Assumptions (checklist)

  • Independent observations (via random assignment).
  • Approximately normal scores within each group.
  • Homogeneity of variance (here, each group variance \(\approx 6\)).

Practice self-test quiz

In the space below, please find practice problems and self-test quizzes. For full access, please signup free.