svgpareto-effects
Pareto chart of effects
Which effects are largest, and which exceed Lenth's margin of error?
How to read it
- Read the bars top down: the largest effects.
- Compare with the margin of error (ME) and the simultaneous margin (SME).
- Bars past SME stand out even after correcting for many comparisons.
- Callout 1: The largest effect.
- Callout 2: ME: the margin of error.
- Callout 3: SME: the simultaneous margin.
Watch out
- Lenth's method assumes few active effects: if most are active, it underestimates the noise.
Defaults
- Margin of error (ME; null = none)
- 6.08
- Lenth's margin: an effect beyond this may be real.
- Range 0 to 1,000,000,000, step 0.01
- Simultaneous margin (SME; null = none)
- 12.36
- Lenth's margin after correcting for testing all effects at once.
- Range 0 to 1,000,000,000, step 0.01
Pinned in the code
- Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
- Bars beyond ME are coloured; ME = t(0.975, d)·PSE with d = m/3 (Lenth 1989); SME uses the simultaneous quantile. The engine computes both.
# Pareto chart of effects — Codesplash Chart Lab (recipe "pareto-effects")
# controls: margin=6.08, smargin=12.36
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("pareto-effects-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")
E = "effect"
V = "|effect|"
ME, SME = 6.08, 12.36
d = df.dropna(subset=[E, V]).assign(a=lambda t: t[V].abs()).sort_values("a") # largest at the top
fig, ax = plt.subplots(figsize=(8, 4.5))
ax.barh(d[E].astype(str), d["a"], color=[PALETTE[1] if ME is None or a > ME else "grey" for a in d["a"]])
if ME is not None: ax.axvline(ME, color=REF, linestyle="--", linewidth=1.2, label=f"ME {ME:g}")
if SME is not None: ax.axvline(SME, color="#ce5342", linestyle=":", linewidth=1.2, label=f"SME {SME:g}")
ax.set_xlabel(V)
ax.legend(fontsize=8)
plt.show()Needs pandas, numpy, matplotlib · reads pareto-effects-demo.csv · app theme from the optional codesplash helper
# Pareto chart of effects — Codesplash Chart Lab (recipe "pareto-effects")
# controls: margin=6.08, smargin=12.36
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("pareto-effects-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")
E = "effect"
V = "|effect|"
ME, SME = 6.08, 12.36
d = df.dropna(subset=[E, V]).assign(a=lambda t: t[V].abs()).sort_values("a")
fig = go.Figure(go.Bar(x=d["a"], y=d[E].astype(str), orientation="h", marker_color=[PALETTE[1] if ME is None or a > ME else "grey" for a in d["a"]]))
if ME is not None: fig.add_vline(x=ME, line=dict(color=REF, dash="dash"), annotation_text="ME")
if SME is not None: fig.add_vline(x=SME, line=dict(color="#ce5342", dash="dot"), annotation_text="SME")
fig.update_layout(xaxis_title=V, yaxis_title=None)
fig.show()Needs pandas, numpy, plotly · reads pareto-effects-demo.csv · app theme from the optional codesplash helper
# Pareto chart of effects — Codesplash Chart Lab (recipe "pareto-effects")
# controls: margin=6.08, smargin=12.36
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("pareto-effects-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["effect"]] <- factor(df[["effect"]])
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
e_col <- "effect"
v_col <- "|effect|"
me <- 6.08; sme <- 12.36
d <- data.frame(e = as.character(df[[e_col]]), a = abs(df[[v_col]]))
d$e <- factor(d$e, levels = d$e[order(d$a)])
d$beyond <- if (is.null(me)) TRUE else d$a > me
p <- ggplot(d, aes(a, e, fill = beyond)) + geom_col() +
{ if (!is.null(me)) geom_vline(xintercept = me, colour = ref_col, linetype = "dashed") } +
{ if (!is.null(sme)) geom_vline(xintercept = sme, colour = "#ce5342", linetype = "dotted") } +
scale_fill_manual(values = c("FALSE" = "grey60", "TRUE" = cs_cat[2]), guide = "none") +
labs(x = v_col, y = NULL) + theme_cs
print(p)Needs ggplot2 · reads pareto-effects-demo.csv · app theme from the optional codesplashr helper