One-Way and Two-Way ANOVA
ANOVA, Correlation, and Regression Significance Tests
Why ANOVA is used
When a study compares more than two group means, performing repeated pairwise t-tests increases the chance of a false-positive result. For example, comparing four groups requires six pairwise tests. If each test has a false-positive risk of 5%, the approximate chance of at least one false alarm is
or about 26% under the simplifying assumption that the tests are independent. The tests are not generally independent, but the example illustrates how repeated testing inflates error risk.
Analysis of variance (ANOVA) tests whether several population means are equal in a single overall test. It does this by comparing variation among the group means with variation among observations within the groups.
ANOVA asks whether the means scatter more than the noise within the groups can explain.
A significant ANOVA result establishes that at least one mean differs; it does not identify which specific groups differ. If the overall test is significant and the particular differences matter, a post-hoc procedure such as Tukey’s test can compare pairs while controlling the multiple-comparison error rate.
One-way ANOVA
Purpose and hypotheses
One-way ANOVA examines one factor at several levels. Examples include comparing:
Several formulations
Different dose levels
Multiple storage conditions
Different machines or analysts
For k groups, the hypotheses are:
Null hypothesis: H0:μ1=μ2=⋯=μk.
Alternative hypothesis: H1: at least one population mean differs from the others.
The alternative does not claim that every mean differs.
Assumptions
One-way ANOVA assumes that:
Observations are selected randomly and are independent.
Each group’s population is approximately normally distributed.
The group populations have approximately equal variances (homogeneity of variance).
How variation is partitioned
Let N be the total number of observations, k the number of groups, ni the number of observations in group i, xˉi the mean of group i, and xˉ the grand mean of all observations.
The total variation around the grand mean is the total sum of squares, SST. It partitions exactly into between-group and within-group variation:
Between-group sum of squares, SSB: variation of group means around the grand mean. It reflects differences among the groups as well as random variation.
SSB=∑i=1kni(xˉi−xˉ)2Within-group sum of squares, SSW: variation of individual observations around their own group means. It estimates background or error variation.
SSW=∑i=1k∑j=1ni(xij−xˉi)2Total sum of squares, SST: variation of every observation around the grand mean.
SST=∑i=1k∑j=1ni(xij−xˉ)2
Under the null hypothesis, between-group variation and within-group variation estimate the same underlying variance. If the means genuinely differ, between-group variation is inflated.
Degrees of freedom, mean squares, and the F statistic
For k groups and N observations:
Between groups: dfB=k−1
Within groups: dfW=N−k
Total: dfT=N−1
The degrees of freedom add up:
Dividing each sum of squares by its degrees of freedom gives a mean square:
The test statistic is:
When the null hypothesis is true, F tends to be near 1. A sufficiently large value indicates that the differences among the means are too large to be readily explained by within-group variation.
One-way ANOVA procedure
State H0 and H1.
Choose the significance level, commonly α=0.05.
Calculate each group mean and the grand mean.
Calculate SSB and SSW.
Check that SST=SSB+SSW.
Calculate the degrees of freedom and mean squares, then form the ANOVA table.
Find the critical table value using numerator degrees of freedom k−1 and denominator degrees of freedom N−k.
Reject H0 if the calculated F exceeds the critical value; state the conclusion in context.
A complete one-way ANOVA table contains:
Between groups: SSB, k−1 degrees of freedom, and MSB=SSB/(k−1).
Within groups (error): SSW, N−k degrees of freedom, and MSW=SSW/(N−k).
Total: SST and N−1 degrees of freedom.
The F ratio uses only the between-groups and within-groups rows. Two useful checks are SST=SSB+SSW and N−1=(k−1)+(N−k).
Worked example: disintegration times
Four tablets from each of three formulations have the following disintegration times, in minutes:
Formulation A: 8,9,7,8
Formulation B: 10,11,9,10
Formulation C: 12,13,11,12
Test whether their mean disintegration times differ at the 5% significance level.
The hypotheses are H0:μA=μB=μC and H1: at least one mean differs.
The group means are:
The total of all observations is 120, so the grand mean is xˉ=120/12=10.
The between-group sum of squares is:
For each group, the squared deviations from its own mean sum to 2. Therefore:
The total sum of squares is SST=38, and the partition check holds:
The ANOVA results are:
Between groups: SS=32, df=2, MS=32/2=16.
Within groups: SS=6, df=9, MS=6/9≈0.667.
Total: SS=38, df=11.
Thus,
For df=(2,9) at the 5% level, the critical value is 4.26. Since 24.0>4.26, H0 is rejected. The formulations differ significantly in mean disintegration time. Their sample means indicate that formulation A disintegrates fastest and formulation C slowest.
The overall ANOVA does not establish which individual pairs differ; that requires an appropriate post-hoc test.
Two-way ANOVA
Purpose and factors
Two-way ANOVA studies two factors in one experiment. For example, a stability study might examine:
Factor A: formulation
Factor B: storage temperature
This approach can estimate the effects of both factors using one experiment. With replicated observations in each factor combination, it can also test whether the effect of one factor depends on the level of the other. This dependence is called an interaction.
For a replicated design, total variation is partitioned as:
where SSA and SSB represent the two factor effects, SSAB represents interaction, and SSE represents residual error.
Two-way ANOVA with one observation per combination
With only one observation for each combination of factor levels, a separate interaction estimate cannot be obtained. The variation left after accounting for the two factor effects serves as error:
In this unreplicated case, interaction cannot be separated from residual error. The factor effects are tested with separate F ratios:
Degrees of freedom in an unreplicated design
For a levels of one factor and b levels of the other:
Factor A: a−1
Factor B: b−1
Error: (a−1)(b−1)
Total: ab−1
For three machines and four operators, the degrees of freedom are:
Machines: 3−1=2
Operators: 4−1=3
Error: (3−1)(4−1)=6
Total: 3(4)−1=11
With one observation per machine–operator combination, interaction is included in the error term and cannot be tested separately.
Worked example: formulation and storage temperature
The assay results, as a percentage of label claim, are:
Formulation A: 96 at 25∘C, 93 at 40∘C, and 87 at 60∘C
Formulation B: 91 at 25∘C, 88 at 40∘C, and 85 at 60∘C
Formulation C: 89 at 25∘C, 83 at 40∘C, and 80 at 60∘C
There is one determination for each formulation–temperature combination.
The row means for formulations A, B, and C are 92, 88, and 84. The column means for 25∘C, 40∘C, and 60∘C are also 92, 88, and 84. The grand mean is 88.
For formulations:
For temperatures:
The total sum of squares is SST=198, so:
The ANOVA results are:
Formulations: SS=96, df=2, MS=48, F=48/1.5=32.0.
Temperatures: SS=96, df=2, MS=48, F=48/1.5=32.0.
Error: SS=6, df=4, MS=1.5.
Total: SS=198, df=8.
For each factor, the critical value at df=(2,4) and the 5% level is 6.94. Both calculated values, F=32.0, exceed the critical value. Both formulation and temperature significantly affect assay. The observed pattern shows assay falling as temperature rises, while formulation A has the highest assay at each temperature.
Each factor requires its own stated F decision and conclusion.
The F distribution and decisions
The F distribution describes the ratio of two variance estimates. Because a variance cannot be negative, F cannot be negative. Its distribution is right-skewed, begins at zero, and extends into a long right-hand tail.
An F distribution is determined by two degrees of freedom:
Numerator degrees of freedom: those of the mean square in the numerator, such as MSB.
Denominator degrees of freedom: those of the error mean square in the denominator.
The F table is entered with the numerator degrees of freedom first, followed by the denominator degrees of freedom. For example:
In the three-formulation one-way problem, df=(2,9) and the 5% critical value is 4.26.
In the two-way stability problem, each factor has df=(2,4) and the 5% critical value is 6.94.
The critical value increases when error degrees of freedom decrease because an error variance estimated from fewer observations is more uncertain. Stronger evidence is then required to reject the null hypothesis.
Results should report both degrees of freedom, for example, F(2,9)=24.0. A bare F value cannot be checked against the correct table entry.
Relationship between ANOVA and the t-test
When a one-way ANOVA compares exactly two independent groups, its test is equivalent to the corresponding pooled-variance two-sample t-test:
The ANOVA numerator degrees of freedom are 1, and its denominator degrees of freedom equal those of the pooled two-sample t-test. Because F is the square of t, the test statistic is nonnegative, but the tests lead to the same decision when used for the same comparison.
Statistical significance and practical importance
A significant F indicates evidence that means differ; it does not establish that the difference is large enough to matter in practice. After a significant result, an investigator should consider:
Which means differ, using a suitable post-hoc test where appropriate
Whether assumptions appear reasonable, including through examination of residuals
Whether the size of the difference matters for the pharmaceutical application
Statistical significance and practical importance are related but separate questions.
Testing the significance of a correlation coefficient
A sample correlation can appear large but still be consistent with chance, especially when there are few observations. To test whether the population correlation is zero, use:
Null hypothesis: H0:ρ=0.
Alternative hypothesis: H1:ρ=0 for a two-sided test.
For sample correlation coefficient r and n pairs of observations:
The calculated t is compared with the critical t value for n−2 degrees of freedom and the chosen significance level.
Worked example: dissolution and bioavailability
A study of 12 formulations gives r=0.85. Then df=12−2=10, and:
The 5% critical value at 10 degrees of freedom is 2.228. Because 5.10>2.228, H0 is rejected. The correlation is statistically significant, supporting an in vitro–in vivo relationship in this example.
A correlation should not be reported as evidence of a relationship without considering its significance, particularly when the sample size is small.
Testing the significance of a regression slope
For a simple linear regression, the slope measures the expected change in the response for a one-unit change in the predictor. To test whether there is no linear relationship:
Null hypothesis: H0:β=0.
Alternative hypothesis: H1:β=0.
For estimated slope b and its standard error SE(b):
A slope significantly different from zero indicates evidence of a linear relationship between predictor and response.
Worked example: calibration regression
A regression based on 12 points gives b=1.85 and SE(b)=0.37. The test statistic is:
At 10 degrees of freedom, the 5% critical value is 2.228. Since 5.00>2.228, the slope is significantly different from zero.
Connection among correlation, slope, and regression ANOVA
In simple linear regression, the test of the slope and the test of the correlation are two forms of the same test. When calculated from the same data, their t statistics agree, apart from rounding. The overall regression can also be tested with an F test in a regression ANOVA table, using the same general comparison of mean squares described for ANOVA.
An intercept can also be tested against a specified hypothesised value using its estimate and standard error.
Practice problems: worked answers
Four tablet presses
Four tablet presses each contribute five tablets. The analysis gives SSB=40 with 3 degrees of freedom and SSW=60 with 16 degrees of freedom.
Between-groups mean square: MSB=40/3≈13.33.
Within-groups mean square: MSW=60/16=3.75.
Test statistic: F=13.33/3.75≈3.56.
Degrees of freedom: F(3,16).
Critical value at 5%: 3.24.
Because 3.56>3.24, the null hypothesis that all four press means are equal is rejected at the 5% level.
Five brands of a drug
For five brands:
Null hypothesis: H0:μ1=μ2=μ3=μ4=μ5.
Alternative hypothesis: H1: at least one brand mean differs.
The number of pairwise comparisons is (25)=10.
Repeated pairwise t-tests are not preferred because each test adds to the overall false-positive risk. ANOVA first tests all five means in one overall test.
Correlation based on ten pairs
For n=10 and r=0.62:
The test is H0:ρ=0 versus H1:ρ=0.
The statistic is t=rn−2/1−r2.
The degrees of freedom are df=8.
The given 5% critical value is 2.306.
The calculated statistic is:
Since 2.24<2.306, the correlation is not significant at the 5% level using the given critical value.
Two-way ANOVA for machines and operators
For three machines and four operators with one observation per combination:
Machines: 2 degrees of freedom
Operators: 3 degrees of freedom
Error: 6 degrees of freedom
Total: 11 degrees of freedom
Because there is only one observation in each combination, the interaction cannot be separated from error.
Two-group ANOVA and F=t2
If the corresponding two-sample t statistic is t=2.92, then:
For a one-way ANOVA comparing two independent groups, the numerator degrees of freedom are 1 and the denominator degrees of freedom are the pooled t-test degrees of freedom, N−2 for N total observations.
Key ideas to retain
One-way ANOVA compares several means for one factor; two-way ANOVA examines two factors in one experiment.
One-way total variation partitions as SST=SSB+SSW.
Two-way ANOVA with replicated combinations can distinguish factor effects, interaction, and error. With one observation per combination, interaction cannot be estimated separately.
The F statistic compares a factor or between-groups mean square with an error mean square.
For exactly two independent groups, the equivalent one-way ANOVA gives F=t2.
Correlation is tested using t=rn−2/1−r2, and a regression slope is tested using t=b/SE(b); both use n−2 degrees of freedom in simple linear regression.
A significant overall test indicates evidence of a difference or relationship, but does not by itself establish which groups differ or whether the effect is practically important.

Ask anything
We've read this whole study set, so questions about it get the best answers.