Repository navigation
Add exact-posterior sampler tests; update NEWS and contributors for #425-#428 - #431
Merged
Merged
Conversation
On a 4-observation, single-tree problem every tree can be enumerated, so the posterior over the number of leaves is known exactly. A 100k-draw chain must match it to within 1 percentage point, for the covariate in ascending and descending order. Fails on main (wrong MH acceptance ratio, and the VarSplitRange extrema bug, which stops descending-order nodes from ever splitting); passes with #425 and #426 applied. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Follow-up to the sampler and random effects fixes from @dwachsmuth in #425, #426, #427, and #428.
Exact-posterior tests (R and Python)
test/python/test_mcmc_exact_posterior.pyandtest/R/testthat/test-mcmc-exact-posterior.Rcheck the MCMC tree sampler against an exactly known answer. On a single-tree problem with four observations (one covariate with values 1-4, zero outcomes,alpha = 0.6,beta = 2,min_samples_leaf = 1, fixed unit variances), every tree can be enumerated, so the posterior over the number of leaves is known exactly (50.183 / 42.176 / 7.196 / 0.446%). A 100,000-draw chain must match each share to within 1 percentage point (more than 5 Monte Carlo standard errors).The covariate is fed in ascending and descending order. The posterior is the same either way, but the order changes which observation each node scans first when computing its split range, which is how the #425 bug shows up. Before the fixes, the descending case never split at all.
Verified against local builds of each stage, in both languages:
Runtime is about 3 s in Python and about 9 s in R; the R sampler test uses
skip_on_cran().NEWS and contributors
NEWS.md: Bug Fixes entries for Fix extrema calculation in MCMC split-range and node-constant helpers #425-Correct the Gaussian random-effects variance conditional #428, plus a note that they change sampler output for a given seed (Fix NaN ordering in GFR feature presorting #427 only for covariates with missing values).DESCRIPTION/man/stochtree-package.Rd: add David Wachsmuth as a contributor.🤖 Generated with Claude Code