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.
翻译:暂无翻译