Skip to content

Bayesian ANOVA as model comparison

Compare models instead of testing terms, read Bayes factors against the null model and between models, and use inclusion Bayes factors for one term at a time.

Advanced ~12 min9 steps

What runs in CodeSplash

You will be able to

  • Read a table of models with Bayes factors and posterior probabilities
  • Compare two models by dividing their Bayes factors
  • Use an inclusion Bayes factor to judge one term across all the models

Read first

01

Models, not terms

Read

Classical ANOVA tests one term at a time. Bayesian ANOVA asks: which model predicted the data best?

With two factors aa and bb, the candidates are:

  • the null, with no factors;
  • aa;
  • bb;
  • a+ba + b;
  • a+b+a×ba + b + a \times b.

Each gets a Bayes factor against the null, and a posterior model probabilityPosterior model probabilityHow probable each model is after the data, given equal prior probabilities for the models compared. when all models start equally likely. An interaction without its main effects isn't considered unless you ask for it.

02

One factor first

Read

With one factor, there is one comparison: the factor against the null.

On simulated data with three groups, BF\text{BF} = 60.4, with a posterior probability of 0.98 for the group model and 0.02 for the null.

On PlantGrowth, the ultrawide prior gives BF\text{BF} = 3.06 and a probability of 0.75. As with the t test, width affects the number, so state it.

03

Predict the best model

Predict

Predict first

Warp breaks in looms are compared across two wools and three tensions. A plot shows that tension's effect is larger for wool A.

Which model do you expect to come out on top?

Tension onlyWool + tensionWool + tension + their interaction
Reveal

The full model, with the interaction: wool + tension + wool × tension. Its BF\text{BF} against the null is 69.6, and its posterior probability is 0.60, so it is the most likely model without being a sure thing.

04

Read the model table

In the app
Bayesian ANOVARecorded · Python and R agreeRecorded 2026-11-17 · 12 values compared
R

BF = 69.62 for wool + tension + wool × tension vs the intercept-only model (r = 0.5)

BF (wool + tension + wool × tension vs null)
69.617
P(best model | data)
0.6017
Inclusion BF: wool
2.769
Inclusion BF: tension
41.753
Inclusion BF: wool × tension
6.042

Plots

Bayes factors of the modelsWhich model of the factors do the data support, and by how much?
View data
BFmodelposterior
0.8185wool0.0071
21.451tension0.1854
22.822wool + tension0.1972
69.617wool + tension + wool × tension0.6017

Assumptions

  • Normal residuals — Shapiro–Wilk on residuals from the cell means: W = 0.987, p = .816.
  • Equal variances — Brown–Forsythe across 6 cells: F = 2.89, p = .023.
  • Independent observations — Between-subjects factors only: each row a separate subject.

Models (against the intercept-only model)

ModelBFlog BFP(model | data)Error %
Intercept only100.00860
wool0.8185−0.20030.00714.596e-8
tension21.4513.0660.18542.819e-7
wool + tension22.8223.1280.19721.772e-6
wool + tension + wool × tension69.6174.2430.60173.851e-6

Inclusion Bayes factors

TermBF (inclusion)
wool2.769
tension41.753
wool × tension6.042

Cell means

wool · tensionnMeanSD
A · H924.55610.273
A · L944.55618.098
A · M9248.660
B · H918.7784.893
B · L928.2229.859
B · M928.7789.431
  • Each term has its own g ~ inverse-gamma(½, r²/2), r = 0.5; effects use orthonormal (Helmert) contrasts; flat intercept, Jeffreys prior on σ².
  • Inclusion Bayes factors compare all models with a term against all models without it (equal prior model probabilities, null included).
  • Bayes factors are relative evidence, not p-values; they are not entered in the multiple-testing ledger.
The exact R script · R R version 4.5.1 (2025-06-13)
# Bayesian ANOVA (model comparison)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method bayes.anova 1.0.1 · spec c5491b2f06b593f4
# Dataset: warpbreaks (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr) # cs_bayes_anova, cs_bayes_prior_scale, cs_bayes_evidence_label (twins of codesplash.stats.bayes)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/warpbreaks.parquet", col_select = c("breaks", "wool", "tension")))
n_input <- nrow(df)
df[["wool"]] <- factor(df[["wool"]], levels = c("A", "B"))  # stored level order
df[["tension"]] <- factor(df[["tension"]], levels = c("L", "M", "H"))  # stored level order
df <- df[stats::complete.cases(df[c("breaks", "wool", "tension")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("breaks", "wool", "tension"))  # infinite values stop the run (registry/errors.yaml)

# %% Models
y <- "breaks"
factor_cols <- c("wool", "tension")
r <- cs_bayes_prior_scale("anova", "medium", 0.5)
which <- "withmain"
codes <- list()
nlev <- integer(0)
for (f in factor_cols) {
  if (nlevels(df[[f]]) < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = f, min = 2, k = nlevels(df[[f]]))
  codes[[length(codes) + 1]] <- as.integer(df[[f]]) - 1L
  nlev <- c(nlev, nlevels(df[[f]]))
}
yv <- as.numeric(df[[y]])
if (length(unique(yv)) < 2) cs_error("CS_E_CONSTANT", column = y)  # no variation: every Bayes factor is 0/0
n <- length(yv)
res <- cs_bayes_anova(yv, codes, nlev, factor_cols, r = r, which = which)
models <- res$models
best <- res$best
labels <- res$labels
full <- models[[length(models)]]

# %% Assumptions (cells = factor combinations)
cell <- do.call(paste, c(lapply(factor_cols, function(f) as.character(df[[f]])), sep = " · "))
cells <- sort(unique(cell), method = "radix")
means <- vapply(cells, function(cc) mean(yv[cell == cc]), numeric(1))
resid <- yv - means[match(cell, cells)]
assumptions <- list()
if (n >= 3 && n <= 5000) {
  sw <- stats::shapiro.test(resid)
  status <- if (sw$p.value < 0.05 && n < 50) "warn" else if (sw$p.value < 0.05) "info" else "pass"
  detail <- sprintf("Shapiro–Wilk on residuals from the cell means: W = %.3f, %s.", sw$statistic, cs_fmt_p(sw$p.value))
} else {
  status <- "info"
  detail <- "Too few (or too many) rows for Shapiro–Wilk on the residuals."
}
assumptions[[length(assumptions) + 1]] <- list(key = "normality", label = "Normal residuals", status = status, detail = detail)
dev <- lapply(cells, function(cc) abs(yv[cell == cc] - stats::median(yv[cell == cc])))
k <- length(cells)
if (n > k && k > 1) {
  grand <- mean(unlist(dev))
  ssb <- sum(vapply(dev, function(d) length(d) * (mean(d) - grand)^2, numeric(1)))
  ssw <- sum(vapply(dev, function(d) sum((d - mean(d))^2), numeric(1)))
  f_bf <- if (ssw > 0) (ssb / (k - 1)) / (ssw / (n - k)) else Inf
  p_bf <- stats::pf(f_bf, k - 1, n - k, lower.tail = FALSE)
  assumptions[[length(assumptions) + 1]] <- list(key = "equal_variance", label = "Equal variances", status = if (p_bf < 0.05) "warn" else "pass",
    detail = sprintf("Brown–Forsythe across %d cells: F = %.2f, %s.", k, f_bf, cs_fmt_p(p_bf)), statistic = f_bf, p = p_bf)
}
assumptions[[length(assumptions) + 1]] <- list(key = "independence", label = "Independent observations", status = "info",
  detail = "Between-subjects factors only: each row a separate subject.")

# %% Result
label <- cs_bayes_evidence_label(best$bf)
summary <- sprintf(
  "The best-supported model is %s: BF = %s against the intercept-only model (%s), posterior probability %.3f with equal prior odds over %d model(s) and the null (prior width r = %s).",
  best$model, cs_fmt_num(best$bf), label, best$posterior, length(models), format(signif(r, 3)))
incl <- res$inclusion
if (length(labels) > 1) {
  summary <- paste0(summary, " Inclusion Bayes factors: ",
                    paste(vapply(names(incl), function(t) sprintf("%s %s", t, cs_fmt_num(incl[[t]])), character(1)), collapse = "; "), ".")
}
cell_rows <- lapply(cells, function(cc) {
  v <- yv[cell == cc]
  list(cell = cc, n = length(v), mean = mean(v), sd = if (length(v) > 1) stats::sd(v) else NULL)
})
stat_rows <- c(
  list(list(key = "bf_best", label = sprintf("BF (%s vs null)", best$model), value = best$bf),
       list(key = "p_best", label = "P(best model | data)", value = best$posterior)),
  lapply(seq_along(incl), function(i) list(key = sprintf("incl_%d", i - 1L), label = sprintf("Inclusion BF: %s", names(incl)[i]), value = incl[[i]]))
)
cs_publish(list(
  method = "bayes.anova",
  methodVersion = "1.0.1",
  title = "Bayesian ANOVA",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = sprintf("BF = %s for %s vs the intercept-only model (r = %s)", cs_fmt_num(best$bf), best$model, format(signif(r, 3))),
  statistics = stat_rows,
  tables = list(
    list(key = "models", title = "Models (against the intercept-only model)",
         columns = list(list(key = "model", label = "Model", type = "string"), list(key = "bf", label = "BF", type = "number"),
                        list(key = "log_bf", label = "log BF", type = "number"), list(key = "posterior", label = "P(model | data)", type = "number"),
                        list(key = "error", label = "Error %", type = "number")),
         rows = c(list(list(model = "Intercept only", bf = 1, log_bf = 0, posterior = res$null_posterior, error = 0)),
                  lapply(models, function(m) list(model = m$model, bf = m$bf, log_bf = m$log_bf, posterior = m$posterior, error = 100 * m$error)))),
    list(key = "inclusion", title = "Inclusion Bayes factors",
         columns = list(list(key = "term", label = "Term", type = "string"), list(key = "bf", label = "BF (inclusion)", type = "number")),
         rows = lapply(names(incl), function(t) list(term = t, bf = incl[[t]]))),
    list(key = "cells", title = "Cell means",
         columns = list(list(key = "cell", label = paste(factor_cols, collapse = " · "), type = "string"), list(key = "n", label = "n", type = "integer"),
                        list(key = "mean", label = "Mean", type = "number"), list(key = "sd", label = "SD", type = "number")),
         rows = cell_rows)
  ),
  effectSizes = list(),
  assumptions = assumptions,
  warnings = warnings,
  notes = list(
    sprintf("Each term has its own g ~ inverse-gamma(½, r²/2), r = %s; effects use orthonormal (Helmert) contrasts; flat intercept, Jeffreys prior on σ².", format(signif(r, 3))),
    "Inclusion Bayes factors compare all models with a term against all models without it (equal prior model probabilities, null included).",
    "Bayes factors are relative evidence, not p-values; they are not entered in the multiple-testing ledger."
  ),
  values = list(
    bf_best = best$bf, best_model = best$model, p_best = best$posterior, bf_full = full$bf,
    bf_incl_1 = incl[[labels[1]]], bf_incl_2 = if (length(labels) > 1) incl[[labels[2]]] else NULL,
    bf_incl_interaction = if (length(labels) > 2) incl[[labels[3]]] else NULL, p_null = res$null_posterior,
    n = n, k_models = length(models), r = r, error_pct = 100 * max(vapply(models, function(m) m$error, numeric(1)))
  ),
  charts = list(cs_chart("models", "bf-models", "Bayes factors of the models",
    list(model = cs_col("model", vapply(models, function(m) m$model, character(1))),
         bf = cs_col("BF", vapply(models, function(m) m$bf, numeric(1))),
         posterior = cs_col("posterior", vapply(models, function(m) m$posterior, numeric(1))))))
))
Python

BF = 69.62 for wool + tension + wool × tension vs the intercept-only model (r = 0.5)

BF (wool + tension + wool × tension vs null)
69.617
P(best model | data)
0.6017
Inclusion BF: wool
2.769
Inclusion BF: tension
41.753
Inclusion BF: wool × tension
6.042

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Normal residuals — Shapiro–Wilk on residuals from the cell means: W = 0.987, p = .816.
  • Equal variances — Brown–Forsythe across 6 cells: F = 2.89, p = .023.
  • Independent observations — Between-subjects factors only: each row a separate subject.

Models (against the intercept-only model)

ModelBFlog BFP(model | data)Error %
Intercept only100.00860
wool0.8185−0.20030.00714.596e-8
tension21.4513.0660.18542.819e-7
wool + tension22.8223.1280.19721.772e-6
wool + tension + wool × tension69.6174.2430.60173.851e-6

Inclusion Bayes factors

TermBF (inclusion)
wool2.769
tension41.753
wool × tension6.042

Cell means

wool · tensionnMeanSD
A · H924.55610.273
A · L944.55618.098
A · M9248.660
B · H918.7784.893
B · L928.2229.859
B · M928.7789.431
  • Each term has its own g ~ inverse-gamma(½, r²/2), r = 0.5; effects use orthonormal (Helmert) contrasts; flat intercept, Jeffreys prior on σ².
  • Inclusion Bayes factors compare all models with a term against all models without it (equal prior model probabilities, null included).
  • Bayes factors are relative evidence, not p-values; they are not entered in the multiple-testing ledger.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Bayesian ANOVA (model comparison)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method bayes.anova 1.0.1 · spec c5491b2f06b593f4
# Dataset: warpbreaks (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd
from scipy import stats

import codesplash as cs
from codesplash.stats import bayes as bf  # default ANOVA Bayes factors (twin of R cs_bayes_anova)

# %% Data
df = pd.read_parquet("tests/parity/fixtures/warpbreaks.parquet", columns=["breaks", "wool", "tension"])
n_input = len(df)
df["wool"] = pd.Categorical(df["wool"], categories=["A", "B"])  # stored level order
df["tension"] = pd.Categorical(df["tension"], categories=["L", "M", "H"])  # stored level order
df = df.dropna(subset=["breaks", "wool", "tension"])  # listwise deletion over the analysis columns
df["wool"] = df["wool"].cat.remove_unused_categories()
df["tension"] = df["tension"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["breaks", "wool", "tension"])  # infinite values stop the run (registry/errors.yaml)

# %% Models
y = "breaks"
factor_cols = ["wool", "tension"]
r = bf.prior_scale("anova", "medium", 0.5)
which = "withmain"
codes, nlev = [], []
for f in factor_cols:
    cats = list(df[f].cat.categories)
    if len(cats) < 2:
        cs.cs_error("CS_E_TOO_FEW_GROUPS", column=f, min=2, k=len(cats))
    codes.append(df[f].cat.codes.to_numpy())
    nlev.append(len(cats))
yv = df[y].to_numpy(dtype=float)
if len(np.unique(yv)) < 2:  # no variation: every Bayes factor is 0/0
    cs.cs_error("CS_E_CONSTANT", column=y)
n = len(yv)
res = bf.anova_bf(yv, codes, nlev, list(factor_cols), r=r, which=which)
models = res["models"]
best = res["best"]
labels = res["labels"]
full = models[-1]

# %% Assumptions (cells = factor combinations)
cell = df[factor_cols].astype(str).agg(" · ".join, axis=1).to_numpy()
cells = sorted(set(cell))
means = {c: yv[cell == c].mean() for c in cells}
resid = yv - np.array([means[c] for c in cell])
assumptions = []
if 3 <= n <= 5000:
    sw = stats.shapiro(resid)
    status = "warn" if sw.pvalue < 0.05 and n < 50 else "info" if sw.pvalue < 0.05 else "pass"
    detail = f"Shapiro–Wilk on residuals from the cell means: W = {sw.statistic:.3f}, {cs.fmt_p(sw.pvalue)}."
else:
    status, detail = "info", "Too few (or too many) rows for Shapiro–Wilk on the residuals."
assumptions.append({"key": "normality", "label": "Normal residuals", "status": status, "detail": detail})
dev = [np.abs(yv[cell == c] - np.median(yv[cell == c])) for c in cells]
k = len(cells)
if n > k and k > 1:
    grand = np.concatenate(dev).mean()
    ssb = sum(len(d) * (d.mean() - grand) ** 2 for d in dev)
    ssw = sum(((d - d.mean()) ** 2).sum() for d in dev)
    f_bf = (ssb / (k - 1)) / (ssw / (n - k)) if ssw > 0 else float("inf")
    p_bf = float(stats.f.sf(f_bf, k - 1, n - k))
    assumptions.append({"key": "equal_variance", "label": "Equal variances", "status": "warn" if p_bf < 0.05 else "pass",
                        "detail": f"Brown–Forsythe across {k} cells: F = {f_bf:.2f}, {cs.fmt_p(p_bf)}.", "statistic": float(f_bf), "p": p_bf})
assumptions.append({"key": "independence", "label": "Independent observations", "status": "info",
                    "detail": "Between-subjects factors only: each row a separate subject."})

# %% Result
label = bf.evidence_label(best["bf"])
summary = (
    f"The best-supported model is {best['model']}: BF = {cs.fmt_num(best['bf'])} against the intercept-only model ({label}), "
    f"posterior probability {best['posterior']:.3f} with equal prior odds over {len(models)} model(s) and the null (prior width r = {r:.3g})."
)
if len(labels) > 1:
    summary += " Inclusion Bayes factors: " + "; ".join(f"{t} {cs.fmt_num(v)}" for t, v in res["inclusion"].items()) + "."
incl = res["inclusion"]
cell_rows = [{"cell": c, "n": int((cell == c).sum()), "mean": float(yv[cell == c].mean()),
              "sd": float(yv[cell == c].std(ddof=1)) if (cell == c).sum() > 1 else None} for c in cells]
cs.publish({
    "method": "bayes.anova",
    "methodVersion": "1.0.1",
    "title": "Bayesian ANOVA",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": f"BF = {cs.fmt_num(best['bf'])} for {best['model']} vs the intercept-only model (r = {r:.3g})",
    "statistics": [
        {"key": "bf_best", "label": f"BF ({best['model']} vs null)", "value": best["bf"]},
        {"key": "p_best", "label": "P(best model | data)", "value": best["posterior"]},
    ] + [{"key": f"incl_{i}", "label": f"Inclusion BF: {t}", "value": v} for i, (t, v) in enumerate(incl.items())],
    "tables": [
        {"key": "models", "title": "Models (against the intercept-only model)",
         "columns": [{"key": "model", "label": "Model", "type": "string"}, {"key": "bf", "label": "BF", "type": "number"},
                     {"key": "log_bf", "label": "log BF", "type": "number"}, {"key": "posterior", "label": "P(model | data)", "type": "number"},
                     {"key": "error", "label": "Error %", "type": "number"}],
         "rows": [{"model": "Intercept only", "bf": 1.0, "log_bf": 0.0, "posterior": res["null_posterior"], "error": 0.0}]
                 + [{"model": m["model"], "bf": m["bf"], "log_bf": m["log_bf"], "posterior": m["posterior"], "error": 100 * m["error"]} for m in models]},
        {"key": "inclusion", "title": "Inclusion Bayes factors",
         "columns": [{"key": "term", "label": "Term", "type": "string"}, {"key": "bf", "label": "BF (inclusion)", "type": "number"}],
         "rows": [{"term": t, "bf": v} for t, v in incl.items()]},
        {"key": "cells", "title": "Cell means",
         "columns": [{"key": "cell", "label": " · ".join(factor_cols), "type": "string"}, {"key": "n", "label": "n", "type": "integer"},
                     {"key": "mean", "label": "Mean", "type": "number"}, {"key": "sd", "label": "SD", "type": "number"}],
         "rows": cell_rows},
    ],
    "effectSizes": [],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [
        f"Each term has its own g ~ inverse-gamma(½, r²/2), r = {r:.3g}; effects use orthonormal (Helmert) contrasts; flat intercept, Jeffreys prior on σ².",
        "Inclusion Bayes factors compare all models with a term against all models without it (equal prior model probabilities, null included).",
        "Bayes factors are relative evidence, not p-values; they are not entered in the multiple-testing ledger.",
    ],
    "values": {
        "bf_best": best["bf"], "best_model": best["model"], "p_best": best["posterior"], "bf_full": full["bf"],
        "bf_incl_1": incl[labels[0]], "bf_incl_2": incl[labels[1]] if len(labels) > 1 else None,
        "bf_incl_interaction": incl[labels[2]] if len(labels) > 2 else None, "p_null": res["null_posterior"],
        "n": n, "k_models": len(models), "r": r, "error_pct": 100 * max(m["error"] for m in models),
    },
    "charts": [cs.chart("models", "bf-models", "Bayes factors of the models",
                        {"model": cs.col("model", [m["model"] for m in models]), "bf": cs.col("BF", [m["bf"] for m in models]),
                         "posterior": cs.col("posterior", [m["posterior"] for m in models])})],
})

Open Models (against the intercept-only model). To compare any two models, divide their Bayes factors:

BFA:B=BFA:0BFB:0\text{BF}_{A:B} = \frac{\text{BF}_{A:0}}{\text{BF}_{B:0}}

How much better is the full model than the runner-up? Look at the Bayes factors of the models chart too.

05

One term across all models

Reflect

Often you ask about one term, not a whole model. An inclusion Bayes factorInclusion Bayes factorThe change from prior to posterior odds that a term belongs in the model, averaged over every model with and without it. compares all the models with that term to all the models without it.

For warp breaks:

  • Wool: 2.77
  • Tension: 41.8
  • Interaction: 6.04

Which term has the strongest support? Why might wool's value be modest even though wool appears in the best model?

06

Is this a p-value in disguise?

Predict

Predict first

A colleague reads the model table as if each row were a test of one term. Is that right?

Yes: you can read each row like an F testNo: each row compares a whole model with the nullOnly with equal group sizes
Reveal

No. Each Bayes factor compares a whole model with the null. To ask about a term, use an inclusion Bayes factor, or divide the Bayes factors of two models that differ by that term alone.

07

Check your understanding

Checkpoint

Check yourself

Model A has BF = 60 against the null, and model B has BF = 15. How many times better did A predict the data than B?

Show the answer

Answer: 4

60/15=460 / 15 = 4. Bayes factors against a common reference divide.

Check yourself

Only two models are compared with equal prior probability: the null and a factor model with BF = 3. What is the posterior probability of the factor model?

Show the answer

Answer: 0.75

3/(1+3)=0.753 / (1 + 3) = 0.75.

Check yourself

Why use an inclusion Bayes factor rather than the Bayes factor of the best model?

Show the answer

Answer: b

When several models are competitive, relying on one overstates what you know. An inclusion Bayes factor takes all of them into account.

08

Do it in CodeSplash

In the app

Choose Outcome and Factors, then Prior width on effects. Models compared defaults to keeping each interaction with its main effects.

Python
# BayesFactor has no standard Python twin; this is the helper the method itself uses.
import pandas as pd
from codesplash.stats import bayes as bf

df = pd.read_csv("warpbreaks.csv")
wool = df["wool"].astype("category").cat.codes.to_numpy()
tension = df["tension"].astype("category").cat.codes.to_numpy()
res = bf.anova_bf(df["breaks"].to_numpy(float), [wool, tension], [2, 3], ["wool", "tension"], r=0.5)
print(res["best"], res["models"])
R
# install.packages("BayesFactor")
library(BayesFactor)
bf <- anovaBF(breaks ~ wool * tension, data = warpbreaks, whichModels = "withmain")
bf
bf[4] / bf[3]  # the full model against wool + tension
09

Recap

Recap
  • Bayesian ANOVA compares models, with Bayes factors against the null and posterior probabilities.
  • Divide two Bayes factors to compare two models.
  • Inclusion Bayes factors judge one term across all models.
  • Report the prior width and how close the competing models are.

Concepts in this lesson