Fix missing MH proposal-SD adaptation under NUTS for GGM and MixedMRF#102
Merged
Conversation
- Centralize stage-3b RM weight in WarmupSchedule::rm_weight_for_proposal_sd.
- Wire GGM and MixedMRF MH paths to MetropolisAdaptationController, mirroring
OMRF. update_* return per-slot accept_prob; do_one_metropolis_step collects
them and calls the adapter(s) once per iteration.
- Decouple NUTS step-size target (default 0.80) from MH componentwise RW MH
target (0.44) in sample_{omrf,ggm,mixed}.cpp.
- Switch GGM proposal_sds_ and MixedMRF proposal_sd_main_continuous_ from
arma::vec to (N, 1) arma::mat so the adapter can hold an arma::mat&.
OMRF/GGM/MixedMRF MH samples bitwise identical to main; MH vs NUTS
per-parameter posterior means agree across all three models (cor > 0.999).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #102 +/- ##
==========================================
- Coverage 87.00% 86.58% -0.43%
==========================================
Files 77 77
Lines 13146 13217 +71
==========================================
+ Hits 11438 11444 +6
- Misses 1708 1773 +65 ☔ View full report in Codecov by Sentry. 🚀 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.
Description
Fix missing MH proposal-SD adaptation under NUTS for GGM and MixedMRF, and align the adaptation machinery across all three concrete models (OMRF, GGM, MixedMRF) so that the bug can't recur silently.
Problem / Motivation
On
main, GGM and MixedMRF chains underupdate_method = "nuts"never adapt the between-model MH proposal SDs. The values used to propose new continuous-parameter values when an edge toggles ON stay at their initial setting for the entire run. The mechanics:tune_proposal_sdis a stub onmain— its body is a comment saying "RM is embedded inupdate_*".update_*functions only fires when those functions are called byMetropolisSampler::step, which is the MH path, not NUTS.update_*functions never run; the inline RM never fires; the proposal SDs stay at their initial value.A second issue, smaller but on the same path, was uncovered during the fix:
validate_sampler.Rdefaultstarget_acceptto0.80(HMC dual-averaging optimum). That value was forwarded toset_metropolis_target_accept, so during stage-3b RM the MH SDs were being tuned to AR ≈ 0.80 instead of the componentwise RW MH optimum 0.44.Proposed Changes / New Functionality
Wire stage-3b proposal-SD adaptation for GGM and MixedMRF under NUTS.
tune_proposal_sdnow performs an actual within-model MH sweep with RM weights, not a stub.MetropolisAdaptationController(one for GGM, five for MixedMRF — one per proposal-SD storage), matching OMRF's pattern. Under MH the controller does per-iteration RM; under NUTS it stays null and stage-3b is the adaptation path.update_*function now returns its per-slot Metropolis acceptance probability (doubleinstead ofvoid).do_one_metropolis_stepcollects them into matrices and calls the adapter(s) once per iteration.Decouple MH and NUTS targets. In
sample_{omrf,ggm,mixed}.cpp, undersampler_type == "nuts"the user'starget_acceptcontinues to drive HMC dual averaging unchanged, butset_metropolis_target_acceptis called with hardcoded0.44so the between-model MH proposal SDs target their own optimum.Consolidate the stage-3b RM weight policy.
WarmupSchedule::rm_weight_for_proposal_sd(iter)is now the single source of truth for the weight schedule and decay rate (proposal_sd_rm_decay = 0.75). Every model'stune_proposal_sdreads it; nobody computes the weight inline.Storage shape. GGM
proposal_sds_and MixedMRFproposal_sd_main_continuous_switched fromarma::vecto(N, 1) arma::matso the controller can hold anarma::mat&reference directly.Type of Change
Documentation and Release Notes
update_*,init_metropolis_adaptation,tune_proposal_sd,sweep_within_model_mh)man/*.Rdfiles if roxygen comments changed (no R-side roxygen changed)NEWS.mdentry if the change affects users (needs an entry — see Additional Notes)Testing and Validation
Verified that:
OMRF/GGM/MixedMRF MH samples are bitwise identical to
main(seed-fixed runs;main,pairwise, andindicatormatrices all match exactly). The MH path is not affected by the NUTS fix.MH and NUTS algorithmic paths agree within each model — per-parameter posterior-mean correlations:
Stage-3b realized acceptance rate converges near 0.44 (target) for all three models post-fix, vs ~0.78 (the wrong NUTS step-size target 0.80) pre-fix.
Checks run:
tests/testthat/when needed (no new R-level surface; existing testthat suite passes)lintr::lint_package()(0 findings)roxygen2::roxygenise()(noman/*.Rdchanges)rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))(0 errors, 0 test failures; 1 warning re missingcheckbashismslocal utility, 1 NOTE re stale DESCRIPTION Date — neither code-related)dev/plans/backlog/align-adaptive-metropolis-path.md): OMRF retains bothMetropolisAdaptationController(per-iteration, MH mode) and the stage-3b path; GGM/MixedMRF now mirror this. Stage 3b is the only place the trans-dimensional edge-toggle proposal SDs get tuned under NUTS — NUTS cannot perform the between-model jump itself — so the two paths serve genuinely different roles. The question is whetherMetropolisAdaptationControllershould also fire during stage 3b under NUTS (or vice versa), not whether stage 3b is redundant.