π€ AI Summary
Traditional piecewise regression models often assume abrupt change points and ignore population heterogeneity, limiting their ability to capture smooth transitions and systematic differences observed in real-world data. This work proposes the smoothbp R package, which implements a Bayesian hierarchical framework incorporating a logistic smooth transition mechanism and KuoβMallick spike-and-slab priors to enable automatic selection of the number of breakpoints. The model accommodates random intercepts, random breakpoints, and covariate effects. Computational efficiency is substantially enhanced through a custom Metropolis-within-Gibbs sampler implemented in Rust, which integrates conjugate updates with Hamiltonian Monte Carlo (HMC). Simulation studies demonstrate that the method yields accurate parameter estimates and well-calibrated posterior inference, outperforming existing tools such as brms and mcp in both modeling flexibility and computational performance.
π Abstract
Piecewise regression models are essential for identifying structural changes in longitudinal or spatial data across diverse scientific domains. While standard approaches often assume sharp, instantaneous transitions and single, non-hierarchical breakpoints, many real-world phenomena exhibit gradual, smoothed transitions that vary systematically across groups. We introduce smoothbp, an R package for fast, Bayesian hierarchical piecewise regression featuring logistic-smoothed transitions. By implementing a bespoke Metropolis-within-Gibbs sampler in Rust, smoothbp combines exact conjugate updates for linear terms with Hamiltonian Monte Carlo (HMC) transitions for non-linear location and sharpness parameters. smoothbp natively supports multiple change-points, random intercepts, random change-point timing, and structural covariates on all segment parameters. It also incorporates Kuo and Mallick (1998) spike-and-slab priors for automatic inference on the number of active breakpoints via the smoothbp_ss function. We document the sampler, validate parameter recovery and calibration through simulation-based calibration and interval-coverage studies, and contrast smoothbp against the existing software landscape across R, Python, Julia, and MATLAB, demonstrating its competitive efficiency against general-purpose probabilistic programming languages like brms and specialized packages like mcp.