svgbf-robustness
Bayes factor robustness
Would a wider or narrower prior change the conclusion?
How to read it
- Read the curve as the Bayes factor at each prior width.
- Find your chosen width on the curve.
- If the curve stays in one evidence band across widths, the conclusion doesn't depend on the prior width.
- Callout 1: Your chosen prior width.
- Callout 2: Evidence band labels.
- Callout 3: The BF = 1 line: no evidence either way.
Watch out
- A range of widths isn't a range of prior shapes: results may still depend on the prior's form.
Defaults
- Chosen prior width
- 0.707
- The prior width used in your analysis, marked on the curve.
- Range 0 to 100, step 0.01
- Log x axis
- Off
- Space the x axis by ratios, which suits values spanning orders of magnitude.
Pinned in the code
- Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
- Shaded bands are Lee & Wagenmakers' (2013) evidence categories after Jeffreys (1961): 1–3 anecdotal, 3–10 moderate, 10–30 strong, 30–100 very strong, above 100 extreme, mirrored below 1 for evidence for H₀.
- Very wide priors favour H₀ (Bartlett–Lindley): a conclusion that holds across the conventional widths is robust; one that flips is prior-sensitive and should be reported as such.
# Bayes factor robustness — Codesplash Chart Lab (recipe "bf-robustness")
# controls: chosen=0.707, logX=false
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
df = pd.read_csv("bf-robustness-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
CUTS = [1 / 30, 1 / 10, 1 / 3, 1, 3, 10, 30] # Lee & Wagenmakers (2013) evidence categories
X = "prior width r"
B = "BF₁₀"
d = df[[X, B]].dropna().query(f"`{B}` > 0").sort_values(X)
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.set_yscale("log")
for cut in CUTS:
ax.axhline(cut, color=REF, linewidth=1.2 if cut == 1 else 0.4, linestyle="--" if cut == 1 else ":")
ax.plot(d[X], d[B], color=PALETTE[0], linewidth=2, label=f"BF₁₀ (last {d[B].iloc[-1]:.3g})")
ax.axvline(0.707, color=REF, linewidth=0.8)
ax.set_xlabel("prior width r")
ax.set_ylabel("BF₁₀ (log scale)")
ax.legend(fontsize=8)
plt.show()Needs pandas, numpy, matplotlib · reads bf-robustness-demo.csv · app theme from the optional codesplash helper
# Bayes factor robustness — Codesplash Chart Lab (recipe "bf-robustness")
# controls: chosen=0.707, logX=false
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
df = pd.read_csv("bf-robustness-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
CUTS = [1 / 30, 1 / 10, 1 / 3, 1, 3, 10, 30] # Lee & Wagenmakers (2013) evidence categories
X = "prior width r"
B = "BF₁₀"
d = df[[X, B]].dropna().query(f"`{B}` > 0").sort_values(X)
fig = go.Figure()
fig.add_scatter(x=d[X], y=d[B], mode="lines", line=dict(color=PALETTE[0], width=2.5), name="BF₁₀")
for cut in CUTS:
fig.add_hline(y=cut, line_color=REF, line_width=1 if cut == 1 else 0.4, line_dash="dash" if cut == 1 else "dot")
fig.add_vline(x=0.707, line_color=REF)
fig.update_layout(xaxis_title="prior width r", yaxis_title="BF₁₀ (log scale)", yaxis_type="log")
fig.show()Needs pandas, numpy, plotly · reads bf-robustness-demo.csv · app theme from the optional codesplash helper
# Bayes factor robustness — Codesplash Chart Lab (recipe "bf-robustness")
# controls: chosen=0.707, logX=false
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
df <- read.csv("bf-robustness-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
tok <- if (has_cs) codesplashr::cs_palette(dark = FALSE) else list()
seq_ramp <- if (is.null(tok$sequential)) c("#eff6fd", "#1a469d") else tok$sequential # low → high
div_ramp <- if (is.null(tok$diverging)) c("#c13e2e", "#f3f5f8", "#0859ac") else tok$diverging # −, 0, +
ref_col <- if (is.null(tok$reference)) "#4e5661" else tok$reference
grey_col <- if (is.null(tok$dim)) "#ced1d6" else tok$dim
X <- "prior width r"
B <- "BF₁₀"
d <- data.frame(x = df[[X]], bf = df[[B]])
d <- d[is.finite(d$x) & is.finite(d$bf) & d$bf > 0, ]
d <- d[order(d$x), ]
cuts <- c(1 / 30, 1 / 10, 1 / 3, 1, 3, 10, 30) # Lee & Wagenmakers (2013) evidence categories
p <- ggplot(d, aes(x, bf)) +
geom_hline(yintercept = cuts, colour = ref_col, linewidth = ifelse(cuts == 1, 0.5, 0.15), linetype = ifelse(cuts == 1, "dashed", "dotted")) +
geom_line(colour = cs_cat[[1]], linewidth = 0.9) +
geom_vline(xintercept = 0.707, colour = ref_col) +
scale_y_log10() +
labs(x = "prior width r", y = "BF10 (log scale)") + theme_cs
print(p)Needs ggplot2 · reads bf-robustness-demo.csv · app theme from the optional codesplashr helper