Bayesian Two-Way ANOVA

Statistics
Introduced by
Harold Jeffreys (foundational); modern default-prior form by Jeffrey N. Rouder et al.
Year
1961 (foundations); 2012 (default Bayes factor formulation)
Type
Bayesian hypothesis test
Family
Classical statistics

What does it do?

Bayesian two-way ANOVA extends the classical two-way analysis of variance by replacing p-values with Bayes factors and posterior distributions.

It quantifies evidence for or against each main effect and for the interaction, using prior-weighted comparison of candidate models. Its conclusions are stated as probabilities and evidence ratios rather than as a decision against a fixed significance threshold.

The intuition behind the method

Consider two categorical factors, such as teaching method and class size, and a continuous outcome such as student performance. Classical ANOVA asks how surprising the data would be if neither factor had an effect. The Bayesian version asks how much more likely the data are under a model that includes a given effect than under one that omits it. This ratio, the Bayes factor, shows whether the evidence favours including the factor, and it can also favour omitting it. Posterior distributions then describe the plausible size of each effect, not only whether it is statistically detectable.

History

The theoretical basis is Harold Jeffreys's framework for Bayesian hypothesis testing with Bayes factors, set out in his Theory of Probability (the cited third edition is dated 1961). The default Bayes factor formulation for ANOVA designs was presented by Rouder, Morey, Speckman, and Province in a 2012 paper in the Journal of Mathematical Psychology.

When to use it

Use Bayesian two-way ANOVA when the outcome is continuous, there are exactly two categorical independent variables, and observations are independent across cells. It is useful when you need evidence for the absence of an effect, which classical ANOVA cannot provide, or when sample sizes are modest and you want the uncertainty in each effect reported explicitly. Do not use it if you cannot justify a prior, or if the audience requires classical p-values. The model assumes independent observations, normal residuals with equal variance across cells, and effect coding in which the effects for each factor sum to zero. Interpret the interaction first; main effects are straightforward to interpret only when the interaction is negligible. Be cautious with very unequal cell counts: the analysis can be run, but the prior and the interpretation of the main-effect Bayes factors need extra checking.

Limitations and considerations

  • Results depend on the prior scale. The g parameter in the model formula controls how wide the effect priors are, so the conclusions should be checked over a range of prior scales.
  • Marginal likelihoods for factorial models require numerical integration or specialised software, so the analysis is more computationally demanding than classical ANOVA.
  • Unbalanced cell counts make main-effect Bayes factors harder to interpret, because the evidence for one factor can depend on how the other factor is distributed across cells.
  • Reviewers and readers in many applied fields are less familiar with Bayes factors, so the manuscript may need more justification and explanation.
  • Software support is narrower than for classical ANOVA; JASP and the BayesFactor R package cover the standard designs, and Stan and brms are used for custom models.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • It can give evidence for the null hypothesis of no effect, so a result can be read as 'evidence of no effect' rather than only 'no effect found'.
  • Bayes factors compare models directly, so each term can be assessed by its own inclusion Bayes factor. Results depend on the prior model probabilities, which should be reported and checked.
  • Posterior distributions give the full range of plausible effect sizes rather than a binary reject or retain decision.
  • Default prior settings in common software allow analysis without manual prior elicitation, although the prior should still be checked (see the limitations).
  • For independent datasets analysed under the same models, Bayes factors can be multiplied to combine evidence across studies.

Applications

  • Psychology experiments testing whether two manipulations (e.g. priming type and cognitive load) jointly affect a continuous response.
  • Education research comparing teaching methods across school types while accounting for possible interactions.
  • Clinical trials with two treatment factors where evidence for the null (no interaction) is as meaningful as evidence against it.
  • Replication studies where accumulating Bayesian evidence across labs is more interpretable than pooling p-values.
  • Neuroscience paradigms with factorial designs needing credible intervals on effect sizes rather than binary decisions.

How it works

How it works

1

The outcome is decomposed into a grand mean, additive main effects for each factor (alpha for factor A, beta for factor B), an interaction term for non-additive joint effects, and residual error. The structure matches classical two-way ANOVA, but it is written as a probabilistic model so that prior distributions can be placed on the parameters.

Formula
y_{ijk} = \mu + \alpha_i + \beta_j + (\alpha\beta)_{ij} + \varepsilon_{ijk}
2

Conditional on a scale parameter g, the main effects and the interaction are given zero-centred normal priors with variance gσ², as written in the model formula. In the default formulation for ANOVA designs (Rouder et al., 2012), g is itself given a prior, so the marginal prior on the effects is a scale mixture of normals of the Jeffreys-Zellner-Siow (JZS) type rather than a single fixed normal. Whether g is fixed by the user or set automatically depends on the software, so the prior actually used should be checked and reported.

Formula
\alpha_i, \beta_j, (\alpha\beta)_{ij} \sim \mathcal{N}(0,\, g\sigma^2)
3

For each candidate model (for example, factor A only, factor B only, both main effects, and both main effects plus the interaction), the marginal likelihood is obtained by integrating out the model parameters under their priors. Bayes factors are ratios of these marginal likelihoods. Values of BF10 above 3 and above 10 are commonly cited as evidence for the alternative model, but these are guidelines rather than cut-offs, and the numerical value should be reported. BF01 = 1/BF10 expresses the same comparison as evidence for the null model, and the same guideline values apply to BF01 when it is read as evidence for the null. State the direction of every reported value explicitly, that is, whether it is BF10 or BF01.

Formula
BF_{10} = \frac{p(\mathbf{y} \mid M_1)}{p(\mathbf{y} \mid M_0)}
4

The factorial sub-models are compared together. The inclusion Bayes factor for a term (each main effect and the interaction) compares the prior-weighted posterior odds of models that contain the term with those of models that do not. In symbols, BF_incl = [Σ over models containing the term of P(M|y) / Σ over models not containing the term of P(M|y)] / [Σ over models containing the term of P(M) / Σ over models not containing the term of P(M)]. The sums run over all candidate models, so the other terms are averaged out using the model prior probabilities as weights. This yields one evidence value per effect of interest. Each term needs its own inclusion Bayes factor, because evidence for one term does not transfer to the others.

5

Posterior distributions for each effect are summarised by a median and a 95% credible interval. A credible interval has a direct probability reading under the chosen prior and model: given the data, the effect lies within the interval with 95% probability. Its width reflects both sample size and prior assumptions, so sensitivity to the prior should be checked.

Common pitfalls

  • Reading a Bayes factor between 1 and 3 as strong evidence for either hypothesis; values in this range indicate only weak or anecdotal support.
  • Reporting a Bayes factor near a conventional threshold without a sensitivity analysis across plausible prior scales.
  • Treating the inclusion Bayes factor for the interaction as evidence about the main effects. Each term needs its own inclusion Bayes factor.
  • Assuming that Bayesian analysis removes sample-size effects. Small samples still give wide posteriors and imprecise Bayes factors.
  • Skipping checks of cell balance and residual normality. The Bayesian analysis uses the same likelihood, so serious violations still bias the results.

Frequently asked questions

How is this different from classical two-way ANOVA?

Classical two-way ANOVA produces F-statistics and p-values that show how surprising the data would be if an effect were absent, but it cannot confirm the absence of an effect. Bayesian two-way ANOVA produces Bayes factors that compare the evidence for competing models, and posterior distributions that describe the likely effect sizes. It can therefore support the conclusion that an effect is probably absent.

Do I need to specify priors manually?

Often not. Packages such as JASP and the BayesFactor R package provide default priors. Check which prior the software uses, because the model formula on this page describes normal priors with scale gσ², conditional on g, and default implementations may differ. Whatever default is used, vary the prior scale and confirm that the conclusions do not change substantially.

What Bayes factor values should I use as guidelines?

Guideline values often cited are BF10 above 3, 10, 30 and 100. These are guidelines, not hard cut-offs. Always report the actual Bayes factor and let readers judge the strength of the evidence. For evidence in favour of the null, report BF01 = 1/BF10 and apply the same values to it.

Can I use this with unbalanced designs?

It can be run, but unbalanced cell counts complicate prior choice and interpretation. Main-effect Bayes factors can respond to imbalance differently from classical Type III sums of squares. Check the cell counts carefully and consult Rouder et al. (2012) or the JASP documentation for guidance on unbalanced Bayesian factorial designs.

Which software can run Bayesian two-way ANOVA?

JASP provides a point-and-click interface with a default prior. The BayesFactor package in R (functions anovaBF and lmBF) offers the same analysis in code. Stan and brms support custom Bayesian models for more complex factorial structures.

Related methods

Sources

  1. Rouder, J. N., Morey, R. D., Speckman, P. L., & Province, J. M. (2012). Default Bayes factors for ANOVA designs. Journal of Mathematical Psychology, 56(5), 356–374.

    Open DOI reference
  2. Jeffreys, H. (1961). Theory of Probability (3rd ed.). Oxford University Press.

    ISBN: 978-0198503682