Skip to main content

The Pinocchio Principle

Building and checking models
Principle or heuristic
Advanced
A model that is created solely for computational reasons can take on a life of its own.
Published

November 9, 2026

Modified

November 13, 2026

Entry #31 in Andrew Gelman’s Handy Statistical Lexicon. Original discussion: Parameterization and Bayesian modeling (PDF).

Filed under Building and checking models · Principle or heuristic · Advanced.

Related terms: half-Cauchy prior, half-t prior, hierarchical variance parameter.

Source check: ✓ The explanation was checked against the source.

What it is

Pinocchio was carved as a puppet and became a real boy. Statisticians sometimes add a parameter or restructure a model purely to make computation easier, such as speeding up a Gibbs sampler or making an integral tractable. Later they discover the computational device has a meaningful interpretation and leads to new, better models. The scaffolding comes to life. As Gelman’s paper puts it: “it is surprisingly common that an existing model is reparameterized, solely for computational purposes, but then this new configuration motivates a new family of models that is useful in applied statistics.” A reparameterization leaves the likelihood unchanged, but “in a Bayesian framework … a transformation of parameters typically suggests a new family of prior distributions.”

Why it matters

Gelman’s example is parameter expansion in hierarchical models. To fix a Gibbs sampler that gets stuck when the group-level variance \(\tau\) is near zero, you write \(\theta_j = \mu + \alpha\,\eta_j\) with a redundant multiplier \(\alpha\). The sampler mixes far better. In addition, the implied prior on \(\tau = |\alpha|\,\sigma_\eta\) is a folded non-central t family, which includes the half-Cauchy. That family became a recommended default prior for hierarchical variance parameters. A computational trick produced a modeling idea.

How it works

With \(\alpha \sim \mathrm{N}(0, A^2)\) and \(\sigma_\eta^2 \sim \text{Inv-}\chi^2(\nu, 1)\) independent, the product \(\tau = |\alpha|\,\sigma_\eta\) has a half-\(t_\nu\) distribution with scale \(A\). The inverse-\(\chi^2\) here must be the scaled version with scale 1, so that \(\sigma_\eta^2 = \nu / X\) with \(X \sim \chi^2_\nu\); with the unscaled \(1/X\), the scale of the half-\(t\) would be \(A/\sqrt{\nu}\) instead. For \(\nu = 1\) this is the half-Cauchy. Here \(\alpha\) was introduced only to break the dependence between \(\tau\) and the \(\theta_j\) in the sampler, but the prior it induces is useful in its own right.

Simulated example

Draw the “computational” parameters \(\alpha\) and \(\sigma_\eta\) from their conditionally conjugate distributions and look at the implied prior on \(\tau\). Compare it with the half-t density the theory predicts.

Show simulation code

The R version uses base R, and the Python version uses NumPy and Matplotlib. Where the simulation draws random numbers, each language draws its own, so exact numbers differ slightly but show the same pattern. The numbered markers in the R code are explained under it.

import {rng, range, fmt, quantile} from "../js/stats.js"

viewof A = Inputs.range([0.5, 10], {value: 2.5, step: 0.5, label: "Scale of α (A)"})
viewof nu = Inputs.range([1, 30], {value: 1, step: 1, label: "Degrees of freedom ν"})
viewof seed = Inputs.range([1, 500], {value: 31, step: 1, label: "Random seed"})

lgamma = z => {
  const g = 7, c = [0.99999999999980993, 676.5203681218851, -1259.1392167224028, 771.32342877765313, -176.61502916214059, 12.507343278686905, -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7];
  // Lanczos approximation; only called here with z >= 0.5.
  z -= 1; let x = c[0]; for (let i = 1; i < g + 2; i++) x += c[i] / (z + i);
  const t = z + g + 0.5; return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(x);
}
halfT = (x, nu, A) => 2 * Math.exp(lgamma((nu + 1) / 2) - lgamma(nu / 2)) / (A * Math.sqrt(nu * Math.PI)) * (1 + (x / A) ** 2 / nu) ** (-(nu + 1) / 2)

taus = {
  const r = rng(seed);
  return range(20000).map(() => Math.abs(r.normal(0, A)) * Math.sqrt(nu / r.chisq(nu)));
}
cap = quantile(taus, 0.95)
density = range(200).map(i => { const x = (i + 0.5) * cap / 200; return {x, d: halfT(x, nu, A)}; })

Plot.plot({
  ariaLabel: "The Pinocchio Principle: simulation chart",
  ariaDescription: "Horizontal axis: Implied prior on τ = |α| σ_η (showing up to the 95th percentile). Vertical axis: Density. The chart updates with the controls above it, and the summary below the charts states the result in words.",
  height: 300,
  x: {label: "Implied prior on τ = |α| σ_η (showing up to the 95th percentile)", domain: [0, cap]},
  y: {label: "Density", grid: true},
  marks: [
    Plot.rectY(taus.filter(t => t < cap), Plot.binX({y: (bin, {x1, x2}) => bin.length / taus.length / (x2 - x1)}, {x: d => d, fill: "#2166ac", fillOpacity: 0.4, thresholds: 60})),
    Plot.line(density, {x: "x", y: "d", stroke: "#d6604d", strokeWidth: 2}),
    Plot.ruleY([0])
  ]
})
# The Pinocchio Principle: a half-t prior on a group-level scale.
1A <- 2.5 # scale of the prior
nu <- 1 # degrees of freedom (1 = half-Cauchy)
2set.seed(31)

# |N(0, A)| * sqrt(nu / chi-squared(nu)) is A times the absolute value of a
# t variable with nu degrees of freedom: a half-t prior
3tau <- A * abs(rt(20000, nu))
print(round(quantile(tau, c(0.5, 0.9, 0.95, 0.99)), 1))

cap <- quantile(tau, 0.95)
4hist(tau[tau < cap],
  breaks = 50, freq = FALSE, col = "grey80",
  border = "white", main = "", xlab = "Group-level scale tau"
)
curve(2 / A * dt(x / A, nu), 0, cap, add = TRUE, col = "#2166ac", lwd = 2)
1
The page’s controls: the scale of the prior and its degrees of freedom (1 gives a half-Cauchy).
2
Fixes the random numbers so the run is reproducible.
3
Draws from the half-t prior: the absolute value of a t variable, scaled by A. The redundant multiplicative parameterization that motivates the principle collapses to this.
4
The histogram of draws with the density overlaid, showing the prior’s heavy tail.
# The Pinocchio Principle: a half-t prior on a group-level scale.
from math import lgamma, pi
import numpy as np
import matplotlib.pyplot as plt

A = 2.5  # scale of the prior
nu = 1   # degrees of freedom (1 = half-Cauchy)
rng = np.random.default_rng(31)

# |N(0, A)| * sqrt(nu / chi-squared(nu)) is A times the absolute value of a
# t variable with nu degrees of freedom: a half-t prior
tau = np.abs(rng.normal(0, A, 20000)) * np.sqrt(nu / rng.chisquare(nu, 20000))
for q in [50, 90, 95, 99]:
    print(f"{q}th percentile: {np.percentile(tau, q):.1f}")


def half_t(x):  # density of the half-t prior
    c = np.exp(lgamma((nu + 1) / 2) - lgamma(nu / 2)) / np.sqrt(nu * pi)
    return 2 / A * c * (1 + (x / A) ** 2 / nu) ** (-(nu + 1) / 2)


cap = np.percentile(tau, 95)
plt.hist(tau[tau < cap], bins=50, density=True, color="0.8")
xs = np.linspace(0, cap, 200)
plt.plot(xs, half_t(xs), color="#2166ac", linewidth=2)
plt.xlabel("Group-level scale tau")
plt.show()

Key takeaways

  • Devices introduced for computation can carry real modeling content.
  • Parameter expansion, meant to speed up Gibbs sampling, gave rise to the half-t family of priors for variance parameters.
  • When a trick works unusually well, ask what model it implies.

Source

Back to top