Skip to content

A number meets a category: point-biserial r and η

How strongly is a numeric variable related to a group? Point-biserial r handles two groups, eta handles several, and omega-squared corrects eta's optimism.

Applied ~9 min9 steps

What runs in CodeSplash

You will be able to

  • Explain point-biserial r as Pearson's r with a 0/1 variable
  • Read η² as the share of variance between groups
  • Choose ω² or ε² when you need a less biased estimate

Read first

01

Correlation with a category

Read

Correlation needs two numbers. But "how strongly is mileage related to transmission type?" is a sensible question, and a group is a kind of number if you code it 0 and 1.

The Pearson correlation between a numeric column and a 0/1 column is called the point-biserial correlationPoint-biserial correlationPearson's correlation between a numeric variable and a two-level variable; it's the same test as a Student t test.. For manual versus automatic cars and mileage, rpbr_{pb} = 0.600, with a 90% interval from 0.37 to 0.76.

Its test is the same test as a Student two-sample tt test, reported differently.

02

More than two groups

Read

With several groups, there's no single direction, so the sign goes away. The correlation ratioCorrelation ratioHow strongly a numeric outcome depends on a categorical variable, allowing any pattern across its levels. η\eta measures how much of the variation lies between groups rather than within them:

η2=SSbetweenSStotal\eta^2 = \frac{SS_{\text{between}}}{SS_{\text{total}}}

It's the R2R^2 of a one-way ANOVA. With two groups, η\eta equals ∣rpb∣|r_{pb}|.

03

Predict the share

Predict

Predict first

Iris flowers come in three species. What share of the variance in sepal length do you think lies between species? Drag to your guess.

Make your guess between 0 and 1 share of variance, then reveal.

Reveal

η² = 0.619, with a 95% interval from 0.52 to 0.68. Species accounts for most of the variation.

04

η² is optimistic

Explore

η2\eta^2 describes your sample, and groups always differ a bit by chance. So it overstates the population value, especially with few rows or many groups. ω2\omega^2 and ϵ2\epsilon^2 correct for this.

BExplorable · η² against ω²

Why does η² overstate the effect in a small ANOVA, and what does ω² do about it?

On average, what does η² report here?

0.50
How sure?
0.00
8
4
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Shrink the sample and watch the gap between them grow. With large samples they nearly agree: here, on 150 flowers, η² = 0.619 and ω² = 0.612.

05

Read the card

In the app
Correlation ratio (η)Recorded · Python and R agreeRecorded 2026-11-17 · 15 values compared · largest relative difference 1.5e-9
R

η² = .62, 95% CI [.52, .68], F(2, 147) = 119.26, p < .001

η
0.7866
η²
0.6187
F
119.26
p
< .001

Effect size

  • η² 0.6187 95% CI [0.5203, 0.6844]
  • ω² 0.6119
  • η 0.7866

Plots

Sepal.Length by SpeciesHow do groups compare in shape, summary and individual observations at once?
View data
SpeciesSepal.Length
setosa5.100
setosa4.900
setosa4.700
setosa4.600
setosa5
setosa5.400
setosa4.600
setosa5
setosa4.400
setosa4.900
setosa5.400
setosa4.800
setosa4.800
setosa4.300
setosa5.800
setosa5.700
setosa5.400
setosa5.100
setosa5.700
setosa5.100
setosa5.400
setosa5.100
setosa4.600
setosa5.100
setosa4.800
setosa5
setosa5
setosa5.200
setosa5.200
setosa4.700
setosa4.800
setosa5.400
setosa5.200
setosa5.500
setosa4.900
setosa5
setosa5.500
setosa4.900
setosa4.400
setosa5.100
setosa5
setosa4.500
setosa4.400
setosa5
setosa5.100
setosa4.800
setosa5.100
setosa4.600
setosa5.300
setosa5
versicolor7
versicolor6.400
versicolor6.900
versicolor5.500
versicolor6.500
versicolor5.700
versicolor6.300
versicolor4.900
versicolor6.600
versicolor5.200

First 60 of 150 rows.

Assumptions

  • Normality within groups — Shapiro–Wilk p ≥ .05 in every group (groups with fewer than 3 values are not tested).
  • Equal variances — Brown–Forsythe F = 6.35, p = .002.

Descriptives

SpeciesnMeanSD
setosa505.0060.3525
versicolor505.9360.5162
virginica506.5880.6359
  • η² = SSbetween / SStotal (3 groups); ε² and ω² correct its upward bias; the η² interval is two-sided.
The exact R script · R R version 4.5.1 (2025-06-13)
# Correlation ratio η and point-biserial r
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method association.eta 1.0.1 · spec ddbaec91382d309b
# Dataset: iris (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/iris.parquet", col_select = c("Sepal.Length", "Species")))
n_input <- nrow(df)
df[["Species"]] <- factor(df[["Species"]], levels = c("setosa", "versicolor", "virginica"))  # stored level order
df <- df[stats::complete.cases(df[c("Sepal.Length", "Species")]), , 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("Sepal.Length", "Species"))  # infinite values stop the run (registry/errors.yaml)

# %% Correlation ratio
y <- "Sepal.Length"
g <- "Species"
conf <- 0.95
levels_g <- levels(df[[g]])
k <- length(levels_g)
if (k < 2) cs_error("CS_E_TOO_FEW_GROUPS", column = g, min = 2, k = k)
values_y <- df[[y]]
groups <- lapply(levels_g, function(lv) df[[y]][df[[g]] == lv])
n <- length(values_y)
if (n <= k) cs_error("CS_E_TOO_FEW_ROWS", what = "The correlation ratio", min = k + 1, n = n)  # no residual degrees of freedom
if (length(unique(values_y)) < 2) cs_error("CS_E_CONSTANT", column = y)  # eta^2 = between / total sum of squares is 0 / 0
grand <- mean(values_y)
ss_total <- sum((values_y - grand)^2)
ss_between <- sum(vapply(groups, function(x) length(x) * (mean(x) - grand)^2, 0))
ss_within <- ss_total - ss_between
df1 <- k - 1
df2 <- n - k
ms_within <- ss_within / df2
f_stat <- (ss_between / df1) / ms_within
p <- pf(f_stat, df1, df2, lower.tail = FALSE)
eta2 <- ss_between / ss_total
eta <- sqrt(eta2)
omega2 <- (ss_between - df1 * ms_within) / (ss_total + ms_within)
epsilon2 <- (ss_between - df1 * ms_within) / ss_total
cohens_f <- sqrt(eta2 / (1 - eta2))
lam <- cs_noncentral_f_ci(f_stat, df1, df2, conf)  # eta^2 = lambda / (lambda + N) (Steiger 2004)
eta2_low <- lam[1] / (lam[1] + n)
eta2_high <- lam[2] / (lam[2] + n)
values <- list()
if (k == 2) {
  # point-biserial: Pearson r between the values and membership of the second group
  pb <- cor.test(values_y, as.numeric(df[[g]] == levels_g[2]), conf.level = conf)
  values <- list(r_pb = unname(pb$estimate), r_pb_ci_low = pb$conf.int[1], r_pb_ci_high = pb$conf.int[2],
                 level_1 = levels_g[1], level_2 = levels_g[2])
}

# %% Assumptions
assumptions <- list()
sw <- lapply(groups, function(x) if (length(x) >= 3 && length(x) <= 5000) shapiro.test(x) else NULL)
bad <- levels_g[vapply(sw, function(s) !is.null(s) && s$p.value < 0.05, logical(1))]
small <- min(lengths(groups)) < 30
status <- if (length(bad) && small) "warn" else if (length(bad) || any(vapply(sw, is.null, logical(1)))) "info" else "pass"
assumptions[[1]] <- list(key = "normality", label = "Normality within groups", status = status,
                         detail = if (length(bad)) paste0(sprintf("Shapiro–Wilk p < .05 in %s", paste(bad, collapse = ", ")),
                                                          if (small) " with fewer than 30 values: the F test's p-value may be off." else "; with 30 or more values per group the F test is robust.")
                                  else "Shapiro–Wilk p ≥ .05 in every group (groups with fewer than 3 values are not tested).")
# Brown-Forsythe: one-way ANOVA on absolute deviations from the group medians
dev <- unlist(lapply(groups, function(x) abs(x - median(x))))
grp <- factor(rep(seq_along(groups), lengths(groups)))
bf_tab <- anova(lm(dev ~ grp))
bf_f <- bf_tab[["F value"]][1]
bf_p <- bf_tab[["Pr(>F)"]][1]
assumptions[[2]] <- list(key = "equal_variance", label = "Equal variances", status = if (bf_p < 0.05) "warn" else "pass",
                         statistic = bf_f, p = bf_p, detail = sprintf("Brown–Forsythe F = %.2f, %s.", bf_f, cs_fmt_p(bf_p)))

# %% Result
pct <- sprintf("%.0f%%", conf * 100)
summary <- sprintf("%s accounts for %.1f%% of the variance in %s (η² = %.3f, %s CI [%.3f, %.3f]); F(%d, %d) = %.2f, %s.",
                   g, eta2 * 100, y, eta2, pct, eta2_low, eta2_high, df1, df2, f_stat, cs_fmt_p(p))
descriptives <- lapply(seq_along(levels_g), function(i) {
  x <- groups[[i]]
  list(group = levels_g[i], n = length(x), mean = mean(x), sd = if (length(x) > 1) sd(x) else NULL)
})
chart_rows <- unique(round(seq(1, n, length.out = min(n, 5000))))
effect_sizes <- list(
  list(key = "eta2", label = "η²", value = eta2, ciLow = eta2_low, ciHigh = eta2_high, ciLevel = conf, method = "SSbetween / SStotal; noncentral-F interval"),
  list(key = "omega2", label = "ω²", value = omega2, method = "less biased population estimate"),
  list(key = "eta", label = "η", value = eta, method = "√η²")
)
if (k == 2) {
  effect_sizes[[4]] <- list(key = "r_pb", label = "Point-biserial r", value = values$r_pb, ciLow = values$r_pb_ci_low,
                            ciHigh = values$r_pb_ci_high, ciLevel = conf, method = sprintf("%s vs %s, Fisher z interval", levels_g[2], levels_g[1]))
}
values <- c(values, list(eta = eta, eta2 = eta2, eta2_ci_low = eta2_low, eta2_ci_high = eta2_high, omega2 = omega2,
                         epsilon2 = epsilon2, cohens_f = cohens_f, f_stat = f_stat, df1 = df1, df2 = df2, p = p, n = n, k = k, bf_p = bf_p, missing_share = if (n_input > 0) n_dropped / n_input else 0))
cs_publish(list(
  method = "association.eta",
  methodVersion = "1.0.1",
  title = "Correlation ratio (η)",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = sprintf("η² = %s, %s CI [%s, %s], F(%d, %d) = %s, %s", cs_fmt_num(eta2, leading_zero = FALSE), pct, cs_fmt_num(eta2_low, leading_zero = FALSE),
                cs_fmt_num(eta2_high, leading_zero = FALSE), df1, df2, cs_fmt_num(f_stat), cs_fmt_p(p)),
  statistics = list(list(key = "eta", label = "η", value = eta), list(key = "eta2", label = "η²", value = eta2),
                    list(key = "f_stat", label = "F", value = f_stat), list(key = "p", label = "p", value = p, format = "p")),
  tables = list(list(key = "descriptives", title = "Descriptives", columns = list(
    list(key = "group", label = g, type = "string"), list(key = "n", label = "n", type = "integer"),
    list(key = "mean", label = "Mean", type = "number"), list(key = "sd", label = "SD", type = "number")), rows = descriptives)),
  effectSizes = effect_sizes,
  assumptions = assumptions,
  warnings = warnings,
  notes = list(sprintf("η² = SSbetween / SStotal (%d groups); ε² and ω² correct its upward bias; the η² interval is two-sided.", k)),
  charts = list(cs_chart("distribution", "raincloud", sprintf("%s by %s", y, g), list(
    y = cs_col(y, values_y[chart_rows]), group = cs_col(g, as.character(df[[g]][chart_rows]), levels = levels_g)))),
  values = values
))
Python

η² = .62, 95% CI [.52, .68], F(2, 147) = 119.26, p < .001

η
0.7866
η²
0.6187
F
119.26
p
< .001

Effect size

  • η² 0.6187 95% CI [0.5203, 0.6844]
  • ω² 0.6119
  • η 0.7866

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

Assumptions

  • Normality within groups — Shapiro–Wilk p ≥ .05 in every group (groups with fewer than 3 values are not tested).
  • Equal variances — Brown–Forsythe F = 6.35, p = .002.

Descriptives

SpeciesnMeanSD
setosa505.0060.3525
versicolor505.9360.5162
virginica506.5880.6359
  • η² = SSbetween / SStotal (3 groups); ε² and ω² correct its upward bias; the η² interval is two-sided.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Correlation ratio η and point-biserial r
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method association.eta 1.0.1 · spec ddbaec91382d309b
# Dataset: iris (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 correlation as cscor

# %% Data
df = pd.read_parquet("tests/parity/fixtures/iris.parquet", columns=["Sepal.Length", "Species"])
n_input = len(df)
df["Species"] = pd.Categorical(df["Species"], categories=["setosa", "versicolor", "virginica"])  # stored level order
df = df.dropna(subset=["Sepal.Length", "Species"])  # listwise deletion over the analysis columns
df["Species"] = df["Species"].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, ["Sepal.Length", "Species"])  # infinite values stop the run (registry/errors.yaml)

# %% Correlation ratio
y, g = "Sepal.Length", "Species"
conf = 0.95
levels = list(df[g].cat.categories)
k = len(levels)
if k < 2:
    cs.cs_error("CS_E_TOO_FEW_GROUPS", column=g, min=2, k=k)
values_y = df[y].to_numpy(dtype=float)
groups = [df.loc[df[g] == lv, y].to_numpy(dtype=float) for lv in levels]
n = len(values_y)
if n <= k:  # no residual degrees of freedom
    cs.cs_error("CS_E_TOO_FEW_ROWS", what="The correlation ratio", min=k + 1, n=n)
if len(np.unique(values_y)) < 2:  # η² = between / total sum of squares is 0 / 0
    cs.cs_error("CS_E_CONSTANT", column=y)
grand = values_y.mean()
ss_total = float(np.sum((values_y - grand) ** 2))
ss_between = float(sum(len(x) * (x.mean() - grand) ** 2 for x in groups))
ss_within = ss_total - ss_between
df1, df2 = k - 1, n - k
ms_within = ss_within / df2
f_stat = (ss_between / df1) / ms_within
p = float(stats.f.sf(f_stat, df1, df2))
eta2 = ss_between / ss_total
eta = float(np.sqrt(eta2))
omega2 = (ss_between - df1 * ms_within) / (ss_total + ms_within)
epsilon2 = (ss_between - df1 * ms_within) / ss_total
cohens_f = float(np.sqrt(eta2 / (1 - eta2)))
lam_low, lam_high = cscor.noncentral_f_ci(f_stat, df1, df2, conf)  # η² = λ / (λ + N) (Steiger 2004)
eta2_low, eta2_high = lam_low / (lam_low + n), lam_high / (lam_high + n)
values = {}
if k == 2:
    # point-biserial: Pearson r between the values and membership of the second group
    ind = (df[g] == levels[1]).to_numpy(dtype=float)
    pb = stats.pearsonr(values_y, ind)
    ci = pb.confidence_interval(confidence_level=conf)
    values.update({"r_pb": float(pb.statistic), "r_pb_ci_low": float(ci.low), "r_pb_ci_high": float(ci.high),
                   "level_1": str(levels[0]), "level_2": str(levels[1])})

# %% Assumptions
assumptions = []
sw = [stats.shapiro(x) if 3 <= len(x) <= 5000 else None for x in groups]
bad = [str(lv) for lv, s in zip(levels, sw) if s is not None and s.pvalue < 0.05]
small = min(len(x) for x in groups) < 30
status = "warn" if bad and small else ("info" if bad or any(s is None for s in sw) else "pass")
assumptions.append({"key": "normality", "label": "Normality within groups", "status": status,
                    "detail": (f"Shapiro–Wilk p < .05 in {', '.join(bad)}" + (" with fewer than 30 values: the F test's p-value may be off." if small else "; with 30 or more values per group the F test is robust."))
                    if bad else "Shapiro–Wilk p ≥ .05 in every group (groups with fewer than 3 values are not tested)."})
bf = stats.levene(*groups, center="median")  # Brown–Forsythe
assumptions.append({"key": "equal_variance", "label": "Equal variances", "status": "warn" if bf.pvalue < 0.05 else "pass",
                    "statistic": float(bf.statistic), "p": float(bf.pvalue),
                    "detail": f"Brown–Forsythe F = {bf.statistic:.2f}, {cs.fmt_p(bf.pvalue)}."})

# %% Result
summary = (
    f"{g} accounts for {eta2:.1%} of the variance in {y} (η² = {eta2:.3f}, {conf:.0%} CI [{eta2_low:.3f}, {eta2_high:.3f}]); "
    f"F({df1}, {df2}) = {f_stat:.2f}, {cs.fmt_p(p)}."
)
descriptives = [{"group": str(lv), "n": len(x), "mean": float(x.mean()), "sd": float(x.std(ddof=1)) if len(x) > 1 else None} for lv, x in zip(levels, groups)]
chart_rows = np.unique(np.round(np.linspace(0, n - 1, min(n, 5000))).astype(int))
effect_sizes = [
    {"key": "eta2", "label": "η²", "value": eta2, "ciLow": eta2_low, "ciHigh": eta2_high, "ciLevel": conf, "method": "SSbetween / SStotal; noncentral-F interval"},
    {"key": "omega2", "label": "ω²", "value": float(omega2), "method": "less biased population estimate"},
    {"key": "eta", "label": "η", "value": eta, "method": "√η²"},
]
if k == 2:
    effect_sizes.append({"key": "r_pb", "label": "Point-biserial r", "value": values["r_pb"], "ciLow": values["r_pb_ci_low"],
                         "ciHigh": values["r_pb_ci_high"], "ciLevel": conf, "method": f"{levels[1]} vs {levels[0]}, Fisher z interval"})
values.update({"eta": eta, "eta2": eta2, "eta2_ci_low": eta2_low, "eta2_ci_high": eta2_high, "omega2": float(omega2),
               "epsilon2": float(epsilon2), "cohens_f": cohens_f, "f_stat": float(f_stat), "df1": float(df1), "df2": float(df2),
               "p": p, "n": n, "k": k, "bf_p": float(bf.pvalue), "missing_share": n_dropped / n_input if n_input else 0.0})
cs.publish({
    "method": "association.eta",
    "methodVersion": "1.0.1",
    "title": "Correlation ratio (η)",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": f"η² = {cs.fmt_num(eta2, leading_zero=False)}, {conf:.0%} CI [{cs.fmt_num(eta2_low, leading_zero=False)}, {cs.fmt_num(eta2_high, leading_zero=False)}], F({df1}, {df2}) = {cs.fmt_num(f_stat)}, {cs.fmt_p(p)}",
    "statistics": [{"key": "eta", "label": "η", "value": eta}, {"key": "eta2", "label": "η²", "value": eta2},
                   {"key": "f_stat", "label": "F", "value": float(f_stat)}, {"key": "p", "label": "p", "value": p, "format": "p"}],
    "tables": [{"key": "descriptives", "title": "Descriptives", "columns": [
        {"key": "group", "label": g, "type": "string"}, {"key": "n", "label": "n", "type": "integer"},
        {"key": "mean", "label": "Mean", "type": "number"}, {"key": "sd", "label": "SD", "type": "number"}], "rows": descriptives}],
    "effectSizes": effect_sizes,
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"η² = SSbetween / SStotal ({k} groups); ε² and ω² correct its upward bias; the η² interval is two-sided."],
    "charts": [cs.chart("distribution", "raincloud", f"{y} by {g}", {
        "y": cs.col(y, values_y[chart_rows]), "group": cs.col(g, df[g].astype(str).to_numpy()[chart_rows], levels=[str(x) for x in levels])})],
    "values": values,
})

The card reports η\eta and η2\eta^2 with ω2\omega^2 and ϵ2\epsilon^2, the FF test, and Cohen's ff. It also runs a Brown–Forsythe check on equal spread: a small p-value there warns that the FF test's equal-variance assumption is doubtful, so look at a Welch ANOVA too.

06

A weak effect, honestly reported

Read

In warpbreaks, wool type and thread breaks give η² = 0.0488, with a 95% interval from 0.00 to 0.19 and p = .108.

The interval runs from nothing up to a respectable share. With 54 rows, the data don't pin this effect down: report that range rather than "no effect".

07

Check your understanding

Checkpoint

Check yourself

A point-biserial correlation test and which other test always give the same p-value?

Show the answer

Answer: a

Point-biserial r is Pearson's r with a 0/1 column, and its t statistic equals the pooled-variance two-sample t.

Check yourself

A one-way analysis has SS between = 30 and SS within = 90. What is η²?

Show the answer

Answer: 0.25

SS total = 30 + 90 = 120, so η² = 30 / 120 = 0.25.

Check yourself

You have 15 rows in 5 groups. Why prefer ω² to η² for a claim about the population?

Show the answer

Answer: b

Chance differences between groups inflate η². ω² subtracts an estimate of that inflation.

08

Do it on your own data

In the app

Choose a numeric Outcome and a categorical Group. With two levels, you also get the point-biserial correlation.

Python
import pandas as pd
from scipy import stats

df = pd.read_csv("iris.csv")
groups = [g["Sepal.Length"].to_numpy() for _, g in df.groupby("Species")]
grand = df["Sepal.Length"].mean()
ss_between = sum(len(g) * (g.mean() - grand) ** 2 for g in groups)
ss_total = ((df["Sepal.Length"] - grand) ** 2).sum()
print("eta2", ss_between / ss_total, stats.f_oneway(*groups))
R
df <- read.csv("iris.csv")
fit <- aov(Sepal.Length ~ Species, data = df)
ss <- summary(fit)[[1]][["Sum Sq"]]
c(eta2 = ss[1] / sum(ss))
summary(fit)
09

Recap

Recap
  • Point-biserial r is Pearson's r with a 0/1 variable and matches the Student tt test.
  • η2\eta^2 is the share of variance between groups, and it runs high in small samples.
  • Use ω2\omega^2 or ϵ2\epsilon^2 for population claims, with an interval.

Concepts in this lesson