svgselection-weights
Selection-model weight function
How much more likely were studies to be published when their one-sided p-value fell in each interval?
How to read it
- Read each step as the relative chance that a study with a one-sided p-value in that interval was published.
- The first interval is fixed at 1; a step at 0.4 means 40% as likely to be published as a study in the first interval.
- Steps near 1 everywhere mean no selection; steps that drop after .025 are what publication bias looks like.
- Callout 1: Significant results: weight fixed at 1.
- Callout 2: Non-significant results published less often.
- Callout 3: Reference line: no selection.
Watch out
- The weights assume selection acted only on p-values; heterogeneity or small-study effects can mimic them.
- Wide bands are common with fewer than about 20 studies; compare with fixed Vevea–Woods weights then.
Defaults
- Log p axis
- On
- Log-scaled p axis from .001 to 1 so the .025 and .05 intervals are visible.
- Reference weight
- 1
- Horizontal reference: 1 means as likely to be published as the first interval.
- Range 0 to 100, step 0.1
Pinned in the code
- Draws the meta-analysis engine's numbers as given (codesplash.stats.meta_lab in Python ≡ codesplashr in R); the chart computes nothing statistical.
- Weights are relative to the first interval (fixed at 1). A weight of 0.5 means half as likely to be published as a study in the first interval.
- Bands are Wald 95% intervals truncated at 0; fixed (a priori) weight functions have no band.
# Selection-model weight function — Codesplash Chart Lab (recipe "selection-weights")
# controls: logP=true, reference=1
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("selection-weights-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")
LO = "p from"
HI = "p to"
W = "weight"
CL = "CI low"
CH = "CI high"
N = "studies"
LOG_P, REFERENCE = True, 1
d = df.dropna(subset=[LO, HI, W]).sort_values(LO)
x_min = min(0.001, d[HI][d[HI] > 0].min() / 2) if LOG_P else 0
left = d[LO].clip(lower=x_min)
fig, ax = plt.subplots(figsize=(7, 4.5))
if CL and CH:
for l, h, a, b in zip(left, d[HI], d[CL], d[CH]):
if np.isfinite(a) and np.isfinite(b):
ax.fill_between([l, h], a, b, color=PALETTE[0], alpha=0.18, lw=0)
ax.hlines(d[W], left, d[HI], color=PALETTE[0], linewidth=2.4)
if N:
for l, h, w, n in zip(left, d[HI], d[W], d[N]):
ax.annotate(f"k = {n:.0f}", (np.sqrt(l * h) if LOG_P else (l + h) / 2, w), textcoords="offset points", xytext=(0, 5), ha="center", fontsize=8)
ax.axhline(REFERENCE, color=REF, linestyle="--", linewidth=1)
if LOG_P:
ax.set_xscale("log")
ax.set_xlim(x_min, 1)
ax.set_ylim(0, None)
ax.set_xlabel(f"one-sided p-value ({LO} to {HI})")
ax.set_ylabel(f"relative chance of publication ({W})")
plt.show()Needs pandas, numpy, matplotlib · reads selection-weights-demo.csv · app theme from the optional codesplash helper
# Selection-model weight function — Codesplash Chart Lab (recipe "selection-weights")
# controls: logP=true, reference=1
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("selection-weights-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")
LO = "p from"
HI = "p to"
W = "weight"
CL = "CI low"
CH = "CI high"
N = "studies"
LOG_P, REFERENCE = True, 1
d = df.dropna(subset=[LO, HI, W]).sort_values(LO)
x_min = min(0.001, d[HI][d[HI] > 0].min() / 2) if LOG_P else 0
fig = go.Figure()
for _, r in d.iterrows():
l = max(r[LO], x_min)
if CL and CH and np.isfinite(r[CL]) and np.isfinite(r[CH]):
fig.add_shape(type="rect", x0=l, x1=r[HI], y0=r[CL], y1=r[CH], fillcolor=PALETTE[0], opacity=0.18, line_width=0)
fig.add_scatter(x=[l, r[HI]], y=[r[W], r[W]], mode="lines", line=dict(color=PALETTE[0], width=3), showlegend=False,
hovertext=f"{r[LO]:g} < p ≤ {r[HI]:g}: {r[W]:.3g}" + (f" (k = {r[N]:.0f})" if N else ""))
fig.add_hline(y=REFERENCE, line_dash="dash", line_color=REF)
fig.update_layout(xaxis_title=f"one-sided p-value ({LO} to {HI})", yaxis_title=f"relative chance of publication ({W})", xaxis_type="log" if LOG_P else "linear")
fig.show()Needs pandas, numpy, plotly · reads selection-weights-demo.csv · app theme from the optional codesplash helper
# Selection-model weight function — Codesplash Chart Lab (recipe "selection-weights")
# controls: logP=true, reference=1
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("selection-weights-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
lo_col <- "p from"
hi_col <- "p to"
w_col <- "weight"
cl_col <- "CI low"
ch_col <- "CI high"
n_col <- "studies"
log_p <- TRUE; reference <- 1
d <- df[!is.na(df[[lo_col]]) & !is.na(df[[hi_col]]) & !is.na(df[[w_col]]), ]
d <- d[order(d[[lo_col]]), ]
x_min <- if (log_p) min(0.001, min(d[[hi_col]][d[[hi_col]] > 0]) / 2) else 0
d$l <- pmax(d[[lo_col]], x_min); d$h <- d[[hi_col]]; d$w <- d[[w_col]]
p <- ggplot(d) +
geom_hline(yintercept = reference, colour = ref_col, linetype = "dashed") +
geom_segment(aes(x = l, xend = h, y = w, yend = w), colour = cs_cat[1], linewidth = 1.2) +
labs(x = paste0("one-sided p-value (", lo_col, " to ", hi_col, ")"), y = paste0("relative chance of publication (", w_col, ")")) + theme_cs
if (!is.null(cl_col) && !is.null(ch_col)) {
b <- d[is.finite(d[[cl_col]]) & is.finite(d[[ch_col]]), ]
p <- p + geom_rect(data = b, aes(xmin = l, xmax = h, ymin = .data[[cl_col]], ymax = .data[[ch_col]]), fill = cs_cat[1], alpha = 0.18)
}
if (!is.null(n_col)) p <- p + geom_text(aes(x = if (log_p) sqrt(l * h) else (l + h) / 2, y = w, label = paste("k =", .data[[n_col]])), vjust = -0.8, size = 3)
if (log_p) p <- p + scale_x_log10()
print(p)Needs ggplot2 · reads selection-weights-demo.csv · app theme from the optional codesplashr helper