Repository navigation
A prior of its own for the ZINB zero-part random effects - #14
Merged
Merged
Conversation
…m effects their own prior Gaussian, probit and NB bart() / bcf() with group ids, cloglog bart(), and default-prior ZINB bart() / bcf() with zero-part random effects (GFR and root chain starts, warm starts), generated from a build of cma-rfx 1273f12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bart() and bcf() take zero_random_effects_params, with any of the six prior keys of random_effects_params. Keys left out take the count part's values, so the default list() keeps the shared prior draw for draw. The zero part's starting values and priors are resolved by .zinbZeroRfxPrior() and used at every place its RandomEffectsModel is set up or reset (initial set-up, GFR and root chain starts, warm starts). The count part's code and the C++ sampler are unchanged: the zero part already has its own model object. Groups, basis and unseen-group policy stay shared and are refused here; a non-empty list without family = 'zinb', group ids and zero_random_effects = TRUE is an error. The roxygen documents the parameter expansion and the exact half-Cauchy mapping (shape = scale = 1/2, working-parameter variance A^2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bitwise references for the unchanged paths; the count prior written out as the zero prior reproduces the default draws; a tight zero prior holds the zero part at every chain start while the count part stays free, and the reverse; a half-Cauchy prior's scale against strong group effects; JSON round trips; validation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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.
What this does
bart()andbcf()takezero_random_effects_params, which sets the prior of the ZINB zero-part random effects separately from the count part's. It accepts the six prior keys ofrandom_effects_params. Keys left out take the count part's values, so the defaultlist()gives the same draws as before. Groups, basis (model_spec) andunseen_groupsstay shared, and the list refuses them. A non-empty list withoutfamily = "zinb", group ids andzero_random_effects = TRUEis an error..zinbZeroRfxPrior()(R/negbin.R) resolves the zero part's starting values and priors. They replace the count part's at every place the zero-partRandomEffectsModelis set up or reset: the initial set-up, GFR and root chain starts, and warm starts with and without previous samples. The C++ needed no change: the zero part already has its own model object, whose priors go through the existing setters. The count part's code is untouched.alpha * xi_k, withalpha ~ N(0, working_parameter_prior_cov),xi_k ~ N(0, s2)ands2 ~ IG(shape, scale)(1 / s2 ~ Gamma(shape, rate = scale)). Both conditionals have zero prior mean; the prior means are starting values only. With shape = scale = 1/2,|alpha| sqrt(s2)is half-Cauchy(0, sqrt(cov)) (Gelman 2006). For example,list(working_parameter_prior_cov = A^2, variance_prior_shape = 0.5, variance_prior_scale = 0.5)gives a half-Cauchy(0, A) prior on the intercept SD. The default (1, 1, cov 1) is half-t₂(0, 1), with prior median 0.82.Tests (
NOT_CRAN=true, installed scratch library, macOS arm64)test-api-combinations.R, "skipping slow tests"). The 13 warnings are upstream sampler notices (cloglog leaf scale, variance-forest σ², multivariate leaf).test-zinb-zero-rfx-prior.R: 88 expectations.fixtures/zinb-zero-rfx-prior-reference.rds, generator alongside): Gaussian, probit and NBbart()/bcf()with group ids, cloglogbart(), and default-prior ZINBbart()/bcf()with zero-part rfx (GFR and root chain starts, warm starts).zinb-rfx-reference.rdschecks (ZINB without group ids, switch off, NB) still pass.Applied check
Run on an internal applied panel (count BCF, 109 groups, 8 chains). With the old call, this branch reproduced an earlier
cma-rfxfit draw for draw.Details are in the internal notes.
🤖 Generated with Claude Code