Skip to content

Accept a Cauchy slab under the hierarchical spec; rename graph_prior_spec#159

Merged
MaartenMarsman merged 5 commits into
developfrom
fix/hier-cauchy-slab
Jul 5, 2026
Merged

Accept a Cauchy slab under the hierarchical spec; rename graph_prior_spec#159
MaartenMarsman merged 5 commits into
developfrom
fix/hier-cauchy-slab

Conversation

@MaartenMarsman

Copy link
Copy Markdown
Collaborator

Two related fixes to the hierarchical precision-graph prior for continuous (GGM) and mixed models.

Accept a Cauchy slab

bgm(x, variable_type = "continuous", graph_prior_spec = "hierarchical") errored with a message demanding a normal interaction prior, even though the default interaction prior is Cauchy. The block was left over from when the Z-ratio normalizer was only derived for the normal slab.

The Cauchy slab is a scale mixture of normals: Cauchy(k; 0, σ) = ∫ N(k; 0, σ²ω) InvGamma(ω; ½, ½) dω. The ω-augmented conjugate move (Gibbs) and the marginal-density moves (adaptive-Metropolis, NUTS) target the same K-marginal, and the Z surrogate is ω-free, so the same normalizer serves all three update methods. The eligibility guard now accepts a normal or a Cauchy interaction prior; no sampler change was needed.

Verified with cross-method inclusion-probability agreement (max difference 0.009 across all edges at q = 6, n = 400) and a new test that fits the spec under each update method.

Clearer, less vague messages

The eligibility errors now name the prior that was supplied and the supported alternatives, and point at graph_prior_spec = "joint" as the fallback, instead of stating a bare requirement.

Rename graph_prior_spec to precision_graph_prior

The argument selects how the prior on the continuous precision block composes with the graph: a joint spike-and-slab prior on (K, Γ), or the hierarchical factorization p(Γ) p(K | Γ). The old name read as configuring the prior on the graph, which is edge_prior's role. The argument has not appeared in a CRAN release, so there is no deprecation shim.

The rename covers bgm(), bgm_spec(), the stored @arguments field, NEWS.md, the roxygen and regenerated man/bgm.Rd, and the tests. sample_ggm_prior() keeps its own short spec argument.

Checks

Targeted tests pass (hierarchical-spec 32/32 including the three-method Cauchy fit, prior-chain identity 8/8, build-arguments field list). R CMD check --as-cran: 0 errors, 0 warnings, 2 environmental NOTEs.

The eligibility check rejected every slab except the normal, but the
Cauchy slab is a scale mixture of normals: conditional on the per-edge
mixture weight it is a normal slab, so the Z-ratio normalizer applies
unchanged. The Gibbs edge move already conditions on the weights, and
the Metropolis and NUTS between-edge moves evaluate the marginal Cauchy
density, which integrates the weights out; all three samplers target
the same posterior. On a synthetic check their inclusion probabilities
agree to within Monte Carlo noise (max difference 0.009 across methods
and edges).

The eligibility messages now name the received prior and the supported
alternatives.
The argument selects how the prior on the continuous precision block
composes with the graph: a joint spike-and-slab prior on (K, Gamma) or
the hierarchical factorization p(Gamma) p(K | Gamma). The old name read
as configuring the prior on the graph itself, which is edge_prior's
role. The argument has not appeared in a CRAN release, so the rename
carries no deprecation shim.

Also updates the prior-chain eligibility test for the Cauchy slab now
being accepted.
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.59459% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.13%. Comparing base (26668ee) to head (e36705e).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
R/sample_ggm_prior.R 57.14% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #159      +/-   ##
===========================================
- Coverage    91.23%   91.13%   -0.11%     
===========================================
  Files          103      103              
  Lines        14520    14516       -4     
===========================================
- Hits         13248    13229      -19     
- Misses        1272     1287      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The rename commit reformatted these files with the default styler
settings (<- assignment, space after if). Reapply the package styler
configuration so they use = assignment and no space after if, matching
the rest of the codebase.
…ssage

The eligibility error for an unsupported interaction prior explained
that the normalizer is derived for the normal slab and that the Cauchy
slab enters through its scale mixture of normals. That describes the
internal representation rather than what the user should do, so state
only that a normal or Cauchy slab is supported. Same change in bgm(),
sample_ggm_prior(), and the bgm() documentation.
The energy-stationarity warmup check is a heuristic, and its message
went straight to "increase warmup". The lower-severity divergence and
tree-depth lines instead point the user at R-hat and ESS. Align the
warmup line with them: report that warmup may be incomplete and direct
the user to check R-hat and ESS rather than prescribing a change.
@MaartenMarsman MaartenMarsman merged commit cef30b8 into develop Jul 5, 2026
8 of 9 checks passed
@MaartenMarsman MaartenMarsman deleted the fix/hier-cauchy-slab branch July 5, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant