Skip to content

BMeta-analysis · meta.escalc

Effect sizes for meta-analysis

What effect size and sampling variance does each study report, on one common scale?

Converts what each study reports — two-arm counts, means and SDs, correlations, ratios with confidence limits or estimates with standard errors — into effect sizes on one scale (log odds or risk ratio, risk difference, Hedges' g, mean difference, Fisher's z, r) with their sampling variances, applying the stated zero-cell correction and leaving out studies that carry no information.

Verified in Python and R Python and R agree to 10 decimals Also called escalc, effect size calculation, log odds ratio…

A real result

Example “Bcg or”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Effect sizes: log odds ratio for 13 studiesRecorded · Python and R agreeRecorded 2026-11-17 · 32 values compared
R

13 studies on the log odds ratio scale.

Studies
13
Unweighted mean log odds ratio
−0.7716

Plots

Study effect sizesHow do the studies' effects compare, and what is the pooled effect and its spread?
View data
odds ratiohighstudylowinverse variance
0.39111.262Aronson 19480.12122.800
0.18900.4621Ferguson & Simes 19490.07734.805
0.25000.9085Rosenthal et al 19600.06882.307
0.23310.3082Hart & Sutherland 19770.176349.226
0.80321.256Frimodt-Moller et al 19730.513819.249
0.38360.4662Stein & Aronson 19530.3156100.96
0.19520.4966Vandiviere et al 19730.07674.405
1.0121.146TPT Madras 19800.8940249.57
0.62390.9961Coetzee & Berjak 19680.390817.551
0.24630.4219Rosenthal et al 19610.143813.259
0.71120.8856Comstock et al 19740.571179.839
1.5636.548Comstock & Webster 19690.37311.872
0.98281.661Comstock et al 19760.581613.960

Assumptions

  • Same scale — Effects are on the log odds ratio scale.

Effect sizes (log odds ratio; 95% CI shown as odds ratio)

StudyyiviSEodds ratioCI lowCI high
Aronson 1948−0.93870.35710.59760.39110.12121.262
Ferguson & Simes 1949−1.6660.20810.45620.18900.07730.4621
Rosenthal et al 1960−1.3860.43340.65830.25000.06880.9085
Hart & Sutherland 1977−1.4560.02030.14250.23310.17630.3082
Frimodt-Moller et al 1973−0.21910.05200.22790.80320.51381.256
Stein & Aronson 1953−0.95810.00990.09950.38360.31560.4662
Vandiviere et al 1973−1.6340.22700.47650.19520.07670.4966
TPT Madras 19800.01200.00400.06331.0120.89401.146
Coetzee & Berjak 1968−0.47170.05700.23870.62390.39080.9961
Rosenthal et al 1961−1.4010.07540.27460.24630.14380.4219
Comstock et al 1974−0.34080.01250.11190.71120.57110.8856
Comstock & Webster 19690.44660.53420.73091.5630.37316.548
Comstock et al 1976−0.01730.07160.26760.98280.58161.661
  • Ratios are analyzed on the log scale; the table shows them back-transformed.
Python

13 studies on the log odds ratio scale.

Studies
13
Unweighted mean log odds ratio
−0.7716

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

Assumptions

  • Same scale — Effects are on the log odds ratio scale.

Effect sizes (log odds ratio; 95% CI shown as odds ratio)

StudyyiviSEodds ratioCI lowCI high
Aronson 1948−0.93870.35710.59760.39110.12121.262
Ferguson & Simes 1949−1.6660.20810.45620.18900.07730.4621
Rosenthal et al 1960−1.3860.43340.65830.25000.06880.9085
Hart & Sutherland 1977−1.4560.02030.14250.23310.17630.3082
Frimodt-Moller et al 1973−0.21910.05200.22790.80320.51381.256
Stein & Aronson 1953−0.95810.00990.09950.38360.31560.4662
Vandiviere et al 1973−1.6340.22700.47650.19520.07670.4966
TPT Madras 19800.01200.00400.06331.0120.89401.146
Coetzee & Berjak 1968−0.47170.05700.23870.62390.39080.9961
Rosenthal et al 1961−1.4010.07540.27460.24630.14380.4219
Comstock et al 1974−0.34080.01250.11190.71120.57110.8856
Comstock & Webster 19690.44660.53420.73091.5630.37316.548
Comstock et al 1976−0.01730.07160.26760.98280.58161.661
  • Ratios are analyzed on the log scale; the table shows them back-transformed.

Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.

Worked examples in the app

  • Bcg orm1_bcg · events_1: events_1 · events_2: events_2 · study: trial · total_1: total_1 · total_2: total_2
  • Bcg rdm1_bcg · events_1: events_1 · events_2: events_2 · study: trial · total_1: total_1 · total_2: total_2
  • Bcg rr allm1_bcg · events_1: events_1 · events_2: events_2 · study: trial · total_1: total_1 · total_2: total_2
  • Normand smdm1_normand · mean_1: mean_1 · mean_2: mean_2 · sd_1: sd_1 · sd_2: sd_2 · study: source · total_1: total_1 · total_2: total_2
  • Molloy corm1_molloy · n: n · r: r · study: study
  • Hackshaw ratiom1_hackshaw · ci_high: or_high · ci_low: or_low · effect: or · study: study
  • Degenerate single levelm1_bcg · events_1: events_1 · events_2: events_2 · study: trial · total_1: total_1 · total_2: total_2

What you need

Study labels (optional)categorical · 0–1 column
Names the studies in tables and the forest plot.
Estimate (or ratio)numeric · 0–1 column
Generic: each study's estimate on an additive scale (log OR, SMD …). With CI limits: the ratio itself (OR, RR, HR).
Standard errornumeric · 0–1 column
Generic design: the estimate's standard error.
Lower CI limit (ratio)numeric · 0–1 column
Ratio with CI design: the reported lower limit; the SE comes from the CI width on the log scale.
Upper CI limit (ratio)numeric · 0–1 column
Ratio with CI design: the reported upper limit.
Events, group 1numeric · 0–1 column
Two-arm counts: events in the first (treatment) arm.
Total, group 1numeric · 0–1 column
Participants in the first arm (counts and means designs).
Events, group 2numeric · 0–1 column
Two-arm counts: events in the second (control) arm.
Total, group 2numeric · 0–1 column
Participants in the second arm (counts and means designs).
Mean, group 1numeric · 0–1 column
Means design: mean of the first arm.
SD, group 1numeric · 0–1 column
Means design: standard deviation of the first arm (not the SE).
Mean, group 2numeric · 0–1 column
Means design: mean of the second arm.
SD, group 2numeric · 0–1 column
Means design: standard deviation of the second arm.
Correlationnumeric · 0–1 column
Correlation design: each study's Pearson r.
Sample size (correlation)numeric · 0–1 column
Correlation design: the number of pairs behind each r.

Choices you make

hypothesis

Study datadefault auto

What each row reports. Auto picks it from the columns you bound.

  • Detect from the columns(default) — Counts → two-arm counts; means → means; r → correlations; CI limits → ratio with CI; else estimate + SE.
  • Two-arm counts — Each study gives events and totals in two arms; pick it for yes/no outcomes.
  • Means and SDs — Each study gives means, SDs and sizes in two arms; pick it for numeric outcomes.
  • Correlations — Each study gives a correlation and its sample size; pick it for associations.
  • Ratio with CI — Each study gives a ratio with its CI, worked back to a log-scale SE; pick it for published OR, RR or HR.
  • Estimate and SE — Each study gives an estimate and its SE; pick it when effects are already computed.
Effect measuredefault auto

The scale studies are pooled on (ratios on the log scale and reported back as ratios).

  • Default for the data(default) — Odds ratio for counts, Hedges' g for means, Fisher's z for correlations.
  • Odds ratio — Odds ratio from two-arm counts; steady across baseline risks, and the usual choice for rare events.
  • Risk ratio — Risk ratio from two-arm counts; easier to explain than odds, on a ratio scale.
  • Risk difference — Risk difference from two-arm counts; gives the absolute effect, which often varies more across studies.
  • Standardized mean difference (Hedges' g) — Mean difference in SD units (Hedges' g); pick it when studies use different scales.
  • Mean difference — Raw units; only when every study measured the outcome on the same scale.
  • Fisher's z (reported as r) — Transforms correlations by Fisher's z before pooling and reports r; the usual choice for correlations.
  • Raw correlation — Pools correlations on their raw scale; easy to read, but each one's variance depends on r.
Confidence leveldefault 0.95

How sure the intervals should be: 0.95 gives 95% confidence intervals. Higher confidence means wider intervals.

options

Zero cellsdefault only0

Continuity correction for log OR / RR when a study has a zero cell.

  • Add ½ to studies with a zero cell(default) — Adds ½ to the cells of studies with a zero; the usual choice.
  • Add ½ to every study — Adds ½ to every study's cells; matches some older software, and pulls small studies towards no effect.
  • No correction (drop undefined) — Adds nothing, so studies with an undefined effect drop out; pick it as a sensitivity check.
Leave out double-zero studiesdefault on

Studies with no events (or only events) in both arms carry no information about OR or RR.

Reported CI level (ratio design)default 0.95

The level of the confidence intervals the studies reported (usually 95%).

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Comparable studiesNot checked from data: state why it holds

    Studies estimate the same kind of effect in comparable populations.

  • Independent estimatesNot checked from data: state why it holds

    One estimate per study; several outcomes or arms from one study need a multilevel model.

  • Same scale

    Mean differences need one measurement scale; otherwise use Hedges' g.

What it reports

k
How many groups, studies or clusters the analysis used. Many methods are less reliable when k is small.
k_left_out
The average effect across studies from a meta-analysis, weighted by each study's precision.
measure
The exact variant that ran (for example Welch vs classic F), shown so the result can be reported and reproduced.
measure_label
The exact variant that ran (for example Welch vs classic F), shown so the result can be reported and reproduced.
yi_mean
Combining several studies' estimates of the same effect into one weighted average, and asking how much they differ.
vi_median
Combining several studies' estimates of the same effect into one weighted average, and asking how much they differ.

Per group, level or term: yi[<study>], vi[<study>]

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-10). Python uses pandas, numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.

Default traps between the two languages

  • Closed-form effect sizes and variances (metafor's large-sample variances; Hedges' g with the exact gamma correction) in both engines.
Python

The exact script CodeSplash ran for example “Bcg or” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Effect sizes for meta-analysis
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method meta.escalc 1.0.1 · spec 8733057cee32c479
# Dataset: m1_bcg (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 meta  # twins of codesplashr::cs_meta_*

# %% Data
df = pd.read_parquet("tests/parity/fixtures/m1_bcg.parquet", columns=["trial", "events_1", "total_1", "events_2", "total_2"])
n_input = len(df)
df["trial"] = pd.Categorical(df["trial"], categories=["Aronson 1948", "Ferguson & Simes 1949", "Rosenthal et al 1960", "Hart & Sutherland 1977", "Frimodt-Moller et al 1973", "Stein & Aronson 1953", "Vandiviere et al 1973", "TPT Madras 1980", "Coetzee & Berjak 1968", "Rosenthal et al 1961", "Comstock et al 1974", "Comstock & Webster 1969", "Comstock et al 1976"])  # stored level order
df = df.dropna(subset=["trial", "events_1", "total_1", "events_2", "total_2"])  # listwise deletion over the analysis columns
df["trial"] = df["trial"].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, ["trial", "events_1", "total_1", "events_2", "total_2"])  # infinite values stop the run (registry/errors.yaml)
# %% Studies
design = "binary"  # inferred from the bound columns
measure = "OR"
cols = {
    "events_1": df["events_1"].to_numpy(dtype=float),
    "total_1": df["total_1"].to_numpy(dtype=float),
    "events_2": df["events_2"].to_numpy(dtype=float),
    "total_2": df["total_2"].to_numpy(dtype=float),
}
es = meta.escalc(design, measure, cols, zero_cells="only0", drop00=True, ci_level=0.95)
measure = es["measure"]
labels_all = df["trial"].astype(str).tolist()
keep = es["keep"]
left_out = [labels_all[i] for i in np.flatnonzero(~keep)]
idx = np.flatnonzero(keep)
y, v = es["yi"][idx], es["vi"][idx]
labels = [labels_all[i] for i in idx]
k = len(y)
if k < 2:
    cs.cs_error("CS_E_TOO_FEW_ROWS", what="A meta-analysis", min=2, n=k)  # one usable study can't be pooled
if left_out:
    warnings.append(f"Left out ({len(left_out)}): " + ", ".join(left_out) + (" — no events (or only events) in both arms." if design == "binary" else " — effect or variance not computable."))
bt = meta.back_transform(measure)
MEASURE_LABEL = {"GEN": "effect", "LOG": "log ratio", "OR": "log odds ratio", "RR": "log risk ratio", "RD": "risk difference",
                 "MD": "mean difference", "SMD": "Hedges' g", "ZCOR": "Fisher's z", "COR": "correlation"}[measure]
RATIO = measure in ("OR", "RR", "LOG")
# What a back-transformed number is: a ratio, not a log ratio; a correlation, not Fisher's z.
DISPLAY_LABEL = {"OR": "odds ratio", "RR": "risk ratio", "LOG": "ratio", "ZCOR": "correlation"}.get(measure, MEASURE_LABEL)

# %% Result
conf = 0.95
zc = float(stats.norm.ppf(1 - (1 - conf) / 2))
se = np.sqrt(v)
lo, hi = y - zc * se, y + zc * se
disp = MEASURE_LABEL.replace("log ", "") if RATIO else MEASURE_LABEL
rows = [{"study": labels[i], "yi": float(y[i]), "vi": float(v[i]), "se": float(se[i]), "estimate": float(bt(y[i])),
         "low": float(bt(lo[i])), "high": float(bt(hi[i]))} for i in range(k)]
values = {"k": k, "k_left_out": len(left_out), "measure": measure, "measure_label": MEASURE_LABEL,
          "yi_mean": float(np.mean(y)), "vi_median": float(np.median(v))}
for i in range(k):
    values[f"yi[{labels[i]}]"] = float(y[i])
    values[f"vi[{labels[i]}]"] = float(v[i])
cs.publish({
    "method": "meta.escalc",
    "methodVersion": "1.0.1",
    "title": f"Effect sizes: {MEASURE_LABEL} for {k} studies",
    "engine": cs.engine_info("numpy", "scipy"),
    "n": k,
    "summary": f"{k} studies on the {MEASURE_LABEL} scale" + (f"; {len(left_out)} left out" if left_out else "") + ".",
    "statistics": [{"key": "k", "label": "Studies", "value": k, "format": "integer"},
                   {"key": "yi_mean", "label": f"Unweighted mean {MEASURE_LABEL}", "value": float(np.mean(y))}],
    "tables": [{"key": "effects", "title": f"Effect sizes ({MEASURE_LABEL}; {conf:.0%} CI shown as {disp})",
                "columns": [{"key": "study", "label": "Study", "type": "string"}, {"key": "yi", "label": "yi", "type": "number"},
                            {"key": "vi", "label": "vi", "type": "number"}, {"key": "se", "label": "SE", "type": "number"},
                            {"key": "estimate", "label": disp, "type": "number"}, {"key": "low", "label": "CI low", "type": "number"},
                            {"key": "high", "label": "CI high", "type": "number"}],
                "rows": rows}],
    "assumptions": [{"key": "scale", "label": "Same scale", "status": "warn" if measure == "MD" else "pass",
                     "detail": "Mean differences assume every study used the same measurement scale." if measure == "MD" else f"Effects are on the {MEASURE_LABEL} scale."}],
    "warnings": warnings,
    "notes": ["Ratios are analyzed on the log scale; the table shows them back-transformed."] if RATIO else [],
    "charts": [cs.chart("effects", "forest-meta", "Study effect sizes",
                        {"label": cs.col("study", labels), "estimate": cs.col(disp, [r["estimate"] for r in rows]),
                         "low": cs.col("low", [r["low"] for r in rows]), "high": cs.col("high", [r["high"] for r in rows]),
                         "weight": cs.col("inverse variance", [float(t) for t in 1 / v])},
                        controls={"reference": 1 if RATIO else 0, "log": RATIO})],
    "values": values,
})
R

The exact script CodeSplash ran for example “Bcg or” · R version 4.5.1 (2025-06-13)

# Effect sizes for meta-analysis
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method meta.escalc 1.0.1 · spec 8733057cee32c479
# Dataset: m1_bcg (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr) # cs_meta_* (twins of codesplash.stats.meta)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/m1_bcg.parquet", col_select = c("trial", "events_1", "total_1", "events_2", "total_2")))
n_input <- nrow(df)
df[["trial"]] <- factor(df[["trial"]], levels = c("Aronson 1948", "Ferguson & Simes 1949", "Rosenthal et al 1960", "Hart & Sutherland 1977", "Frimodt-Moller et al 1973", "Stein & Aronson 1953", "Vandiviere et al 1973", "TPT Madras 1980", "Coetzee & Berjak 1968", "Rosenthal et al 1961", "Comstock et al 1974", "Comstock & Webster 1969", "Comstock et al 1976"))  # stored level order
df <- df[stats::complete.cases(df[c("trial", "events_1", "total_1", "events_2", "total_2")]), , 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("trial", "events_1", "total_1", "events_2", "total_2"))  # infinite values stop the run (registry/errors.yaml)
# %% Studies
design <- "binary"  # inferred from the bound columns
measure <- "OR"
cols <- list(
  events_1 = as.numeric(df[["events_1"]]),
  total_1 = as.numeric(df[["total_1"]]),
  events_2 = as.numeric(df[["events_2"]]),
  total_2 = as.numeric(df[["total_2"]]),
  NULL
)
cols <- Filter(Negate(is.null), cols)
es <- cs_meta_escalc(design, measure, cols, zero_cells = "only0", drop00 = TRUE, ci_level = 0.95)
measure <- es$measure
labels_all <- as.character(df[["trial"]])
keep <- es$keep
left_out <- labels_all[!keep]
idx <- which(keep)
y <- es$yi[idx]; v <- es$vi[idx]
labels <- labels_all[idx]
k <- length(y)
if (k < 2) cs_error("CS_E_TOO_FEW_ROWS", what = "A meta-analysis", min = 2, n = k)  # one usable study can't be pooled
if (length(left_out)) {
  warnings <- c(warnings, paste0(sprintf("Left out (%d): ", length(left_out)), paste(left_out, collapse = ", "),
                                 if (design == "binary") " — no events (or only events) in both arms." else " — effect or variance not computable."))
}
bt <- cs_meta_back(measure)
MEASURE_LABEL <- c(GEN = "effect", LOG = "log ratio", OR = "log odds ratio", RR = "log risk ratio", RD = "risk difference",
                   MD = "mean difference", SMD = "Hedges' g", ZCOR = "Fisher's z", COR = "correlation")[[measure]]
RATIO <- measure %in% c("OR", "RR", "LOG")
# What a back-transformed number is: a ratio, not a log ratio; a correlation, not Fisher's z.
DISPLAY_LABEL <- if (measure %in% c("OR", "RR", "LOG", "ZCOR")) c(OR = "odds ratio", RR = "risk ratio", LOG = "ratio", ZCOR = "correlation")[[measure]] else MEASURE_LABEL

# %% Result
conf <- 0.95
zc <- stats::qnorm(1 - (1 - conf) / 2)
se <- sqrt(v)
lo <- y - zc * se; hi <- y + zc * se
disp <- if (RATIO) sub("log ", "", MEASURE_LABEL) else MEASURE_LABEL
rows <- lapply(seq_len(k), function(i) list(study = labels[i], yi = y[i], vi = v[i], se = se[i], estimate = bt(y[i]), low = bt(lo[i]), high = bt(hi[i])))
values <- list(k = k, k_left_out = length(left_out), measure = measure, measure_label = MEASURE_LABEL, yi_mean = mean(y), vi_median = stats::median(v))
for (i in seq_len(k)) {
  values[[sprintf("yi[%s]", labels[i])]] <- y[i]
  values[[sprintf("vi[%s]", labels[i])]] <- v[i]
}
cs_publish(list(
  method = "meta.escalc",
  methodVersion = "1.0.1",
  title = sprintf("Effect sizes: %s for %d studies", MEASURE_LABEL, k),
  engine = cs_engine_info("stats", "nanoparquet"),
  n = k,
  summary = paste0(sprintf("%d studies on the %s scale", k, MEASURE_LABEL), if (length(left_out)) sprintf("; %d left out", length(left_out)) else "", "."),
  statistics = list(list(key = "k", label = "Studies", value = k, format = "integer"),
                    list(key = "yi_mean", label = paste("Unweighted mean", MEASURE_LABEL), value = mean(y))),
  tables = list(list(key = "effects", title = sprintf("Effect sizes (%s; %.0f%% CI shown as %s)", MEASURE_LABEL, conf * 100, disp),
                     columns = list(list(key = "study", label = "Study", type = "string"), list(key = "yi", label = "yi", type = "number"),
                                    list(key = "vi", label = "vi", type = "number"), list(key = "se", label = "SE", type = "number"),
                                    list(key = "estimate", label = disp, type = "number"), list(key = "low", label = "CI low", type = "number"),
                                    list(key = "high", label = "CI high", type = "number")),
                     rows = rows)),
  assumptions = list(list(key = "scale", label = "Same scale", status = if (measure == "MD") "warn" else "pass",
                          detail = if (measure == "MD") "Mean differences assume every study used the same measurement scale." else sprintf("Effects are on the %s scale.", MEASURE_LABEL))),
  warnings = warnings,
  notes = if (RATIO) list("Ratios are analyzed on the log scale; the table shows them back-transformed.") else list(),
  charts = list(cs_chart("effects", "forest-meta", "Study effect sizes",
                         list(label = cs_col("study", labels), estimate = cs_col(disp, bt(y)), low = cs_col("low", bt(lo)), high = cs_col("high", bt(hi)),
                              weight = cs_col("inverse variance", 1 / v)),
                         controls = list(reference = if (RATIO) 1 else 0, log = RATIO))),
  values = values
))

Sources

  • Hedges, L. V. (1981). Distribution theory for Glass's estimator of effect size. Journal of Educational Statistics, 6, 107–128.
  • Borenstein, M., Hedges, L. V., Higgins, J. P. T., & Rothstein, H. R. (2009). Introduction to Meta-Analysis. Wiley.
  • Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3).

From the CodeSplash method registry · meta.escalc v1.0.1.