1 One-way ANOVA
1.1 Purpose and basic model
One-way ANOVA (analysis of variance) tests whether the mean of a continuous outcome differs across three or more independent groups that are defined by a single categorical factor. The method expresses each observation as the sum of a group mean and an error term. In its simplest form, groups share the same error variance, and the only systematic differences come from the factor levels.
A common notation writes the outcome in group \(i\) as: \[ Y_{ij} = \mu_i + \varepsilon_{ij}, \] where \(\mu_i\) is the mean for group \(i\) and \(\varepsilon_{ij}\) is residual noise. The overall goal is to decide whether the group means \(\mu_1, \mu_2, \ldots\) appear different beyond what random fluctuation would produce.
1.2 Assumptions and diagnostics
1.2.1 Independence of observations
The validity of the test relies on observations being independent within and across groups. Practically, dependence can arise from repeated measurements treated as separate cases, clustering (e.g., students within classrooms), or paired designs. Independence is usually addressed by study design (random sampling or appropriate experimental structure) and by confirming that the data collection scheme matches the analysis.
Diagnostics are not as direct as for normality; instead, analysts rely on design documentation and checks such as reviewing sampling procedures or assessing whether outcomes appear correlated within known clusters.
1.2.2 Normality of residuals
ANOVA uses the residuals (errors) rather than the raw outcomes. The residuals within each group should be approximately normally distributed for the standard \(F\) test to have good behavior, particularly in small samples. When sample sizes are moderate to large, the test becomes more robust to mild non-normality, but extreme skewness or heavy tails can still distort inference.
Typical diagnostics include quantile–quantile (Q–Q) plots of residuals and formal tests that quantify deviations from normality. In modern practice, visual checks and context-driven judgment are often emphasized over a single p-value from a normality test.
1.2.3 Homogeneity of variances
One-way ANOVA assumes equal variances across groups. When group spread differs substantially, the pooled variance estimate used in the \(F\) statistic may be inappropriate, affecting both type I error rates and power. Heteroscedasticity is more problematic when group sizes are unequal, because the influence of each group on the pooled estimate changes.
Variance diagnostics may include plotting residual spreads by group and using statistical checks for equality of variance. Analysts often combine these tools with domain knowledge about whether equal-variance behavior is plausible.
1.3 Hypotheses and interpretation
The classic hypothesis test compares whether all group means are equal:
- Null hypothesis: \(H_0:\mu_1=\mu_2=\cdots=\mu_k\)
- Alternative hypothesis: at least one mean differs
If the resulting \(F\) test is statistically significant, the analysis supports evidence that the factor is associated with different group averages. A key interpretation point is that ANOVA does not identify which groups differ; it only indicates that not all means are equal. Determining pairwise or structured differences requires post-hoc comparisons or planned contrasts.
1.4 ANOVA table and mean square decomposition
The ANOVA table organizes variability into between-group and within-group components. Conceptually, it decomposes total sum of squares into:
- Sum of squares between groups (explained by the factor)
- Sum of squares within groups (unexplained residual error)
Each component is divided by its degrees of freedom to form mean squares: \[ F = \frac{\text{Mean Square Between}}{\text{Mean Square Within}}. \] Under the null hypothesis, the between-group mean square is expected to be similar in size to the within-group mean square, because any apparent differences should be explainable by noise alone.
1.5 Effect size measures
Statistical significance alone does not quantify how large the group differences are. Effect size measures complement the \(F\) test by describing the proportion of variability attributable to the factor.
Common measures include:
- \(\eta^2\): a ratio of explained sum of squares to total sum of squares
- \(\omega^2\): an estimate adjusted for bias that often provides a more reliable assessment in finite samples
- Partial \(\eta^2\): used in multi-factor contexts when controlling for other effects
Selecting an effect size should align with the design and the reporting conventions in the field, with attention to whether adjustment for bias is desired.
1.6 Post-hoc comparisons
After a significant one-way ANOVA, post-hoc procedures compare pairs of group means while controlling error rates across multiple tests. The choice depends on goals such as strict control of family-wise error or assumptions about equal variances and balanced group sizes.
Because many comparisons increase the chance of false positives, post-hoc adjustments are essential for credible pairwise statements.
1.6.1 Tukey HSD
Tukey’s honestly significant difference (HSD) is designed for all pairwise mean comparisons under equal-variance assumptions. It controls the family-wise error rate across the set of comparisons, making it a standard choice when the primary question concerns which groups differ from one another.
Tukey HSD tends to be appropriate when:
- group sizes are reasonably similar, and
- the equal-variance assumption is defensible.
1.6.2 Scheffé and planned contrasts
Scheffé’s method is more conservative and applies more broadly, including situations involving complex comparisons rather than only pairwise differences. It provides control under a wide range of contrasts, which can be useful when the analysis includes many possible linear combinations of means.
Planned contrasts, by contrast, are specified in advance based on hypotheses (e.g., comparing a control group to the average of treatment groups). Planned contrasts can be more powerful when the hypotheses are truly pre-specified, because the multiple-testing burden is structured rather than treating all pairwise differences as equally important.
2 Multi-factor (Factorial) ANOVA
2.1 Two-way ANOVA
Two-way ANOVA extends one-way ANOVA by including two categorical factors and their effects on a continuous outcome. A typical two-way design evaluates:
- the main effect of factor A (differences among its levels, averaged over factor B),
- the main effect of factor B (differences among its levels, averaged over factor A),
- and the A-by-B interaction (whether the factor effects depend on the other factor’s level).
The model allows each factor to shift group means and allows the size or direction of shifts to vary across the cross-classified conditions.
2.1.1 Main effects
A main effect is interpreted as an overall difference in marginal averages. For example, if factor A has significant main effect, it suggests that the mean outcome changes across the levels of A when B is averaged out.
Main effects do not reveal whether differences are consistent across conditions; that information is often carried by the interaction term.
2.1.2 Interaction effects
An interaction occurs when the effect of one factor is different at different levels of the other factor. In mean terms, the pattern of differences across levels of A is not the same for all levels of B.
When interaction is present, focusing only on main effects can be misleading. Interpretation typically emphasizes how the combination of factors shapes the outcome, often using interaction plots and follow-up simple-effects analyses.
2.1.3 Simple effects and marginal means
Simple effects examine differences at a specific level of one factor within each level of the other. Analysts often compute marginal means and simple effects to clarify the nature of an interaction.
Marginal means summarize averages across the levels of a factor, while simple effects drill into conditional comparisons. Many practical workflows report both, using interaction-aware post-hoc tests to determine which comparisons drive the interaction.
2.2 Higher-order factorial designs
2.2.1 Three-way and beyond
Three-way ANOVA includes three categorical factors and evaluates not only main effects and two-way interactions, but also a three-way interaction. Higher-order designs increase interpretive complexity because multiple interaction layers can coexist.
As dimensionality rises, analysts typically use structured visualization, clear reporting of degrees of freedom and sums of squares, and planned post-hoc strategies guided by theory rather than purely exploratory searching.
2.2.2 Interaction interpretation pitfalls
A frequent pitfall is interpreting main effects as if they represent uniform differences across all conditions, even when interactions exist. Another issue is over-reliance on p-values without considering effect sizes and uncertainty.
Interaction terms are also sometimes misunderstood as “more significance,” rather than as evidence of non-additivity: the joint effect of factors cannot be described as a simple sum of individual effects.
2.3 Balanced vs. unbalanced designs
Balanced designs have equal numbers of observations in each factor level combination. Unbalanced designs involve unequal group sizes. Balanced structures often simplify computation and improve the stability of variance estimates.
In unbalanced settings, main effects and interaction sums of squares can depend on how the model is parameterized. Analysts typically use marginal means frameworks and careful contrast coding to ensure interpretations align with the intended scientific question.
Unbalanced data also interact with heteroscedasticity concerns; when variances differ and sample sizes are unequal, the standard ANOVA assumptions become more fragile.
3 Repeated Measures ANOVA
3.1 Within-subjects structure
Repeated measures ANOVA is used when the same subjects are observed under multiple conditions (e.g., measurements at several time points). Because observations from the same individual are correlated, the analysis must account for within-subject dependence.
The model separates between-subject variability (stable differences among individuals) from within-subject variability (changes across conditions). This distinction increases sensitivity by removing subject-to-subject noise from comparisons among conditions.
3.2 Sphericity assumption
Sphericity is a condition controlling the pattern of variances of the differences between all pairs of repeated conditions. When sphericity holds, the covariance structure among repeated measures has a specific equality pattern that allows a standard \(F\) test.
If sphericity is violated, the nominal significance level of the test can become too liberal (too many false positives), especially as the number of repeated conditions increases.
3.2.1 Mauchly’s test
Mauchly’s test is a commonly used procedure to assess whether sphericity is violated. A significant result suggests that the sphericity assumption is not met, motivating the use of correction factors for degrees of freedom.
Because this test can be sensitive to sample size and design details, many analysts treat it as diagnostic guidance rather than as a strict decision rule.
3.2.2 Epsilon corrections (Greenhouse–Geisser, Huynh–Feldt)
Epsilon (\(\epsilon\)) corrections adjust the degrees of freedom for the repeated-measures tests to better control type I error under sphericity violation. Greenhouse–Geisser is commonly used as a conservative default, while Huynh–Feldt can be less conservative in some circumstances.
Corrected degrees of freedom change the effective strength of the test without altering the underlying model’s mean structure, producing more trustworthy p-values.
3.3 Modeling correlated observations
Repeated measures ANOVA addresses correlation through the repeated structure in the error terms. Conceptually, it models the covariance among observations within a subject, at least to the extent required by the sphericity framework.
When the covariance structure is more complex than what sphericity-based ANOVA can represent, alternative modeling approaches (such as mixed-effects models) may provide more flexible and robust fits. Nonetheless, repeated measures ANOVA remains a widely used tool in controlled settings with a manageable number of conditions.
3.4 Interpreting within-subject effects
Within-subject effects evaluate whether the mean outcome changes across repeated conditions within the same individuals. Interpretation depends on whether the analysis includes factor interactions (e.g., treatment by time) and whether corrections were applied.
It is often helpful to report estimated marginal means for each condition, along with confidence intervals, because repeated measures ANOVA can produce a significant overall test even when some pairwise differences are small or consistent only in certain comparisons.
4 Assumption Checking and Robust Alternatives
4.1 Residual analysis workflow
Assumption checking typically begins with residuals from the fitted model. Because ANOVA’s inferential procedures depend on the error structure, residual-based diagnostics offer more direct evidence than inspecting raw group means alone.
A practical workflow focuses on both the shape of the residual distribution and the spread pattern across groups or fitted values.
4.1.1 Plots and normality checks
Residual plots can reveal skewness, heavy tails, and outliers. A Q–Q plot compares residual quantiles to the expected normal quantiles, highlighting systematic departures. A residuals versus fitted values plot can also help diagnose whether any nonlinearity or variance changes are present.
Analysts often use these visuals together rather than relying exclusively on any single diagnostic statistic.
4.1.2 Variance diagnostics
Variance diagnostics examine whether residual variability remains roughly constant across groups or across predicted levels. When variances differ strongly, standard ANOVA may not be reliable.
Variance diagnostics may include residual spread by group, as well as formal tests when appropriate. Even then, the decision to switch methods often depends on how severe the deviation is and whether sample sizes are balanced.
4.2 Transformations and remedies
When assumptions are questionable, transformations of the outcome can stabilize variance and improve approximate normality. Common choices depend on the nature of the data, such as logarithmic transforms for positive skew or square-root transforms for count-like outcomes.
Transformations change interpretation: means on the transformed scale do not directly equal means on the original scale. Analysts should ensure that reporting and back-transformations match the audience’s expectations.
Other remedies include removing or investigating extreme outliers, rechecking data entry, and reconsidering the study design when dependence or heteroscedasticity cannot be justified.
4.3 Nonparametric and robust analogs
4.3.1 Kruskal–Wallis overview
Kruskal–Wallis is a rank-based alternative to one-way ANOVA. It tests whether distributions (often interpreted as medians under certain conditions) differ across groups without requiring normality of residuals.
While Kruskal–Wallis provides robustness to non-normality, it does not directly test equality of means in the same way as ANOVA. Interpretation typically relies on the rank framework and assumptions about similar distribution shapes.
4.3.2 Welch’s ANOVA
Welch’s ANOVA addresses heterogeneity of variances by modifying the test statistic and degrees of freedom. It is particularly useful when group variances differ and group sizes are unequal, situations where standard ANOVA’s pooled variance becomes problematic.
Welch’s approach preserves the core mean-comparison objective while reducing reliance on equal variance.
3.3.3 Games–Howell post-hoc (unequal variances)
Games–Howell is a post-hoc method designed for pairwise comparisons under unequal variances and unequal sample sizes. It controls family-wise error in a way that aligns with Welch-style variance flexibility.
This procedure is often paired with Welch’s ANOVA when the global test indicates differences and variance assumptions do not hold.
5 Model Extensions and Related Methods
5.1 ANCOVA (ANOVA with covariates)
5.1.1 Covariate adjustment
ANCOVA (analysis of covariance) incorporates continuous covariates alongside a categorical factor. The goal is to adjust group comparisons for systematic variation explained by measured covariates.
In a typical linear ANCOVA, the outcome is modeled as a combination of a group effect, a covariate effect (often linear), and an error term. By controlling for the covariate, differences among adjusted group means become more interpretable.
5.1.2 Assumptions for linear covariates
A central assumption is that the relationship between the covariate and the outcome is appropriately modeled (commonly linear). Another important requirement is the homogeneity of regression slopes: the covariate effect should be similar across groups if the standard ANCOVA formulation is used.
Violations can bias adjusted group comparisons. Checking covariate–outcome linearity and testing for interaction between covariate and group are common validation steps.
5.2 Generalized linear modeling perspective
5.2.1 When ANOVA is not appropriate
ANOVA is naturally suited to continuous outcomes that can be modeled with normally distributed errors and additive effects. When outcomes are binary, counts, or otherwise non-normal with a mean–variance relationship that differs from the normal model, generalized linear modeling (GLM) may be more appropriate.
From this perspective, ANOVA can be viewed as a special case within broader regression frameworks. The choice of link function and distribution in GLM aligns the model to the data-generating process more closely than a forced normal-error assumption.
5.3 Linear mixed-effects models vs. repeated measures ANOVA
5.3.1 Random effects interpretation
Linear mixed-effects models generalize ANOVA by incorporating random effects, which represent sources of variability beyond fixed group-level factors. In repeated-measures settings, random effects can capture subject-specific baselines and potentially subject-specific trajectories.
Random effects provide a principled way to model correlation among repeated observations without relying solely on sphericity. This flexibility is particularly valuable when individuals have different patterns over time.
5.3.2 Handling missing data
Repeated measures ANOVA typically assumes balanced data or, at minimum, missingness that is handled in a limited way. Mixed-effects models can accommodate unbalanced observation counts and certain missing-at-random mechanisms through likelihood-based estimation.
In practice, this can reduce bias and improve usability when some subjects miss one or more conditions, provided the missingness assumptions are defensible.
6 Practical Workflow in Data Analysis
6.1 Study design and factor coding
Before fitting models, analysts translate the study into factors and levels. This includes defining which variables are categorical predictors, how many groups each factor has, and whether the design is balanced.
Factor coding also includes choosing reference levels for regression-style implementations and specifying contrast coding schemes for interpreting effects. Clear factor definitions reduce ambiguity in how marginal means and interactions are computed.
6.2 Computing ANOVA (formula overview)
6.2.1 Degrees of freedom logic
Degrees of freedom determine the scale of each sum of squares component and the reference distribution for the \(F\) test. In one-way ANOVA, between-group degrees of freedom relate to the number of groups, while within-group degrees of freedom relate to the total sample size minus the number of estimated group means.
Understanding degrees of freedom helps verify implementation: errors often manifest as incorrect table entries or mismatched p-values.
6.2.2 F-statistic and p-values
The \(F\) statistic is the ratio of mean square for the factor effect to mean square for residual error. Under the null hypothesis and given assumptions, the \(F\) statistic follows an \(F\)-distribution with corresponding numerator and denominator degrees of freedom.
P-values derive from comparing the observed \(F\) to this reference distribution. Robust and heteroscedasticity-aware variants modify degrees of freedom or the variance estimate, changing the p-value calculation accordingly.
6.3 Choosing contrasts and reference levels
Contrasts define how the model compares group means. For example, one contrast might test whether the first group differs from the average of remaining groups, while another might represent a trend across ordered factor levels.
Selecting contrasts should follow the research question. Reference levels affect interpretation in regression outputs, but contrasts and estimated marginal means clarify the scientific meaning of the parameters.
6.4 Reporting results
6.4.1 Effect sizes and confidence intervals
Good reporting includes not only p-values but also effect sizes and uncertainty. Confidence intervals for mean differences, effect sizes, or estimated marginal means communicate the range of plausible values and improve interpretability.
In factorial or repeated-measures designs, it is common to report effect sizes for main and interaction effects and to provide follow-up comparisons with appropriate adjustments.
6.4.2 Presenting ANOVA tables clearly
An ANOVA table typically reports sums of squares, degrees of freedom, mean squares, \(F\) statistics, and p-values for each source of variation. Clear labeling of the factor terms (and, when relevant, corrected degrees of freedom for repeated measures) reduces reader confusion.
For multi-factor designs, it is also helpful to mention whether the design is balanced, whether corrections were applied, and which post-hoc strategy was used when interpreting significant effects.