MyNixOS website logo
Description

Prior-Fraction Diagnostics for Hierarchical Models.

Computes the prior fraction, the per-group pooling or shrinkage factor, for hierarchical models, including directly from 'brms' fits. For each group-level coefficient the prior fraction is the share of the posterior precision contributed by the shrinkage prior relative to the likelihood; values near one indicate a coefficient that is prior-dominated (the centring/non-centring funnel regime), values near zero indicate a likelihood-dominated coefficient that is well identified from the data. These quantities are invisible to standard convergence diagnostics such as R-hat and effective sample size, and they indicate where a non-centred reparameterisation is likely to help. A companion advisor reports the same decomposition for changepoint random effects fitted with 'smoothbp'. The underlying geometry (the Fisher-metric connection on the base-fiber split, for which this connection is flat so the obstruction is statistical rather than geometric) is described in Bindoff (2026) <doi:10.5281/zenodo.20724550>; code reproducing the paper is in the package's source repository.

fibr

Prior-fraction diagnostics for hierarchical models.

Overview

Standard MCMC diagnostics (R̂, ESS, divergence counts) report whether a chain has mixed, not which parameters are causing slow mixing or why. For hierarchical models the centring/non-centring trade-off is the dominant obstruction, and it varies across groups within a single fit.

fibr computes the prior fraction

π_j = (1/σ²) / G_{FF,j}

for each group-level coordinate: the share of that coordinate's posterior precision contributed by the prior rather than by the data. This is the classical shrinkage/pooling factor (Gelman & Pardoe 2006) and the per-group information ratio of Betancourt & Girolami (2015). The companion paper shows that once the Ehresmann connection on the base–fiber bundle is known to be flat, π_j is not a heuristic but the unique quantity governing the centring obstruction.

Coordinates with π_j near 1 are prior-dominated: their posteriors reflect regularisation toward the population mean rather than group-specific data. Coordinates with π_j near 0 are data-driven. The same quantity gives the per-group non-centring weight for partial reparameterisation.

The installed package is deliberately small: prior_fraction() (with a brms method) and the smoothbp_advisor() companion. The geometry that motivates it — the analytic connection, curvature, the chain-level coupling diagnostic, and the experimental connection-corrected samplers — is reproduction code for the paper and lives in the source repository's paper/ directory rather than in the installed package, because the paper proves this connection is flat (so those quantities are statistical, not a user-facing geometric diagnostic).

Installation

# from CRAN (once available)
install.packages("fibr")

# or the development version
# install.packages("remotes")
remotes::install_github("ABindoff/fibr")

Requires R ≥ 4.1.0. The brms adapter for prior_fraction() requires brms and a Stan backend (cmdstanr or rstan).

Usage

Prior fraction from a brms fit

library(brms)
library(fibr)

fit <- brm(y ~ 1 + (1 | site), data = dat, family = poisson(),
           chains = 4, cores = 4)

pf <- prior_fraction(fit)
print(pf)   # summary: how many coordinates exceed the 0.8 threshold
plot(pf)    # π_j vs. log(n_obs) per coordinate

Supported families: gaussian, bernoulli, binomial, poisson, negbinomial. Correlated random effects are handled per-marginal with a diagnostic message.

Manual path (any model)

# Supply prior precision and per-group likelihood information directly.
# For a Gaussian outcome: likelihood information = n_j / sigma_y^2.
# For Bernoulli: sum of p_i(1-p_i) within each group.
sigma_re <- 1.5
n_obs    <- c(2, 5, 20, 80)
sigma_y  <- 1.0

prior_fraction(1 / sigma_re^2, lik_information = n_obs / sigma_y^2)

This path works for Stan, JAGS, or any other fitting engine. The helper fibr:::.glm_information() computes per-observation Fisher weights from the linear predictor for the supported GLM families.

Reproducing the paper

The analytic connection, curvature, chain-level coupling diagnostic, and the connection-corrected samplers are not part of the installed package. They live in paper/R/ and are loaded with:

source("paper/setup.R")   # run from the repository root

after which compute_connection(), holonomy_diagnostic(), and the samplers are available, and the scripts in data-raw/ regenerate the paper's figures. See paper/README.md. This route needs the heavier dependencies (Matrix, FNN, deSolve, patchwork, a Stan backend) that the CRAN package does not.

Background

The joint parameter space of a two-level hierarchical model — hyperparameters (μ, σ) as the base, group parameters (α₁, …, α_J) as the fibers — carries a fiber bundle structure. The Fisher information metric induces an Ehresmann connection A = −G_FF⁻¹ G_BF on this bundle. A natural conjecture is that the centring obstruction arises from the curvature of this connection, manifesting as holonomy when the hyperparameters traverse a closed loop.

The companion paper proves this false for any smooth hierarchical posterior: the connection is flat, its horizontal leaves being the level sets of the fiber score ∂_α log p, so no geometric obstruction exists above the metric level. The non-zero curvature seen when integrating the linearised (fiber-frozen) connection is an artefact of that approximation; numerical verification is in data-raw/verify_flat_connection.R and paper/tests/test-connection.R.

What remains is statistical: the conditional dependence of fiber on base, governed per group by π_j. Genuine curvature — including rotational holonomy — does appear for connections built from a sampler's working metric (a fixed mass matrix) rather than the true Hessian, making holonomy an algorithmic rather than geometric phenomenon in that setting.

Reference

Bindoff, A.D. (2026). A Flat Connection: The Pooling Factor and the Geometry of Centring in Hierarchical MCMC. Preprint. https://doi.org/10.5281/zenodo.20724550

@misc{bindoff2026fibr,
  author = {Bindoff, Aidan D.},
  title  = {A Flat Connection: The Pooling Factor and the Geometry of
             Centring in Hierarchical {MCMC}},
  year   = {2026},
  doi    = {10.5281/zenodo.20724550},
  url    = {https://github.com/ABindoff/fibr}
}
Metadata

Version

0.1.1

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows