Exponential default for the precision diagonal; gamma-shape corrections for the Z-ratio and Gibbs paths#168
Merged
Conversation
…ision diagonal The default precision_scale_prior becomes exponential_prior(eta = 1), the same GammaScalePrior(1, rate) as the previous gamma_prior(shape = 1, eta = 1) at the C++ level; a seeded-fit identity test pins the equivalence. The conjugate_slab gate in extract_prior_inclusion_probabilities() now admits both family strings, keeping the prior-only chain on the Gibbs path under the new default.
…) diagonal
The channel builders carry the diagonal prior K_ii ~ Gamma(alpha, beta)
with the prior weight on the raw diagonals. The spike integral gains a
(s1 s2)^(alpha-1) factor, evaluated by a vectorized generalized
Gauss-Laguerre rule on the shifted product form with the exponentially
scaled Bessel; the slab pair and bridge integrals move their diagonal
axes to generalized Gauss-Laguerre (weight S^(alpha-1) e^(-beta S)); the
node channel folds the weight into the tilt exponent (delta + alpha);
and the clique-2 sweep corrects the alpha = 1 conjugate proposal by an
independence-Metropolis ratio (K_ii_new/K_ii_old)^(alpha-1). The
constants cell and session cache key extend to (delta, eta, alpha,
slab); zratio_cell_constants() accepts scale_shape. At alpha = 1 every
path keeps the existing expressions and RNG stream bit-exactly.
Each generalized channel is checked against a direct Monte Carlo of the
same moment ratio at alpha in {0.5, 2} (normal and Cauchy slabs), the
generalized Laguerre rule against gamma moments, and the spike integral
against stats::integrate; the alpha = 1 engine fixtures are unchanged.
ZRatioEngine gains an alpha parameter (default 1) on set_oracle_params() and enable_calibration(). The block-Gibbs sweep keeps the alpha = 1 conjugate row proposal and accepts with the independence-Metropolis ratio (K_ii_new/K_ii_old)^(alpha-1); the neighborless diagonal draws rgamma(delta + alpha, beta) and the block seed draws rgamma(alpha, beta) at alpha != 1. sample_ggm/sample_mixed read an optional zratio alpha field, and the test interfaces expose it. At alpha = 1 every path draws the identical RNG sequence; the engine reference fixtures are unchanged. An alpha = 2 consistency gate checks the additive tables and the calibrated estimator against the long-run block oracle.
Remove the shape-1 stops in bgm_spec and sample_ggm_prior, pass scale_shape into zratio_cell_constants() on the GGM, mixed, and prior-sampler paths, and forward the cell's alpha to the C++ engine. The graph-law identity gate now runs at shape 0.5 and 2 on both update methods (Bernoulli(0.3) marginal within 0.02 at q = 6), the standardized-cell invariance check covers the gamma cell, and the hierarchical bgm() eligibility test replaces the shape-2 error pin with a shape-2 fit.
The row-block Gibbs at shape != 1 (independence-MH accept (K_ii_new/K_ii_old)^(shape-1) on the joint row proposal) gets two gates: a cross-sampler agreement test against adaptive Metropolis on the same joint-spec prior at shape 2 (mean and per-column KS on thinned diagonals), and a slow-gated SBC block (Gibbs, Gamma(2, 1) diagonal, p = 3, no edge selection) reusing the existing harness via a shape parameter on draw_prior_K. Docs and NEWS drop the shape-1 requirement from the hierarchical spec and describe the generalized constants.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #168 +/- ##
===========================================
- Coverage 91.08% 90.97% -0.11%
===========================================
Files 104 104
Lines 14952 14996 +44
===========================================
+ Hits 13619 13643 +24
- Misses 1333 1353 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
precision_scale_priorfor continuous models is now the namedexponential_prior(eta = 1). Numerics are bit-identical to the previousgamma_prior(shape = 1, eta = 1)(both resolve toGammaScalePrior(1, rate)); a seeded-fit identity test pins the equivalence. Theconjugate_slabgate inextract_prior_inclusion_probabilities()now admits both family strings instead of keying on"gamma", which would have demoted prior-only chains from the Gibbs path under the new default.gamma_prior()diagonals of any shape. The Z-ratio constants generalize from the exponential to aGamma(shape, rate)diagonal with the prior weight on the raw diagonals: generalized Gauss-Laguerre pair and bridge axes, a shape-shifted node channel (delta + shape), a vectorized generalized-Laguerre spike integral (exactGamma(nu)^2 beta^(-2 nu)limit at c = 0,nu = delta + shape), and an independence-Metropolis correction(K_ii_new/K_ii_old)^(shape - 1)in the clique-2 sweep and the calibration-oracle Gibbs. The constants cell and session cache extend to(delta, eta, shape, slab), andscale_shapeflows from the spec throughrun_sampler()/sample_ggm_prior()into the C++ engine.Gamma(2, 1)diagonal, p = 3).Verification
test-zratio-gamma-shape.R); generalized-Laguerre moment identities; spike integral againststats::integrate.(delta, eta, shape)across frames.R CMD check --as-cran0 errors / 0 warnings.