Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a conditional_effects() S3 method for bmmfit objects to make extracting/plotting predictor effects on model parameters more intuitive, including correct back-transformations to native parameter scales (and special handling for mixture-model weight parameters). It also updates mixture-model link specifications to reflect the actual transformations used internally.
Changes:
- Add
conditional_effects.bmmfit()withpar+scalesupport, internal-effect filtering, and special softmax handling formixture3p. - Add shared parameter/link helper utilities (
.get_parameter_info(),.is_softmax_param(),link_transform()support). - Correct declared links for mixture-model parameters (
mixture2p/mixture3p), plus documentation/vignette/pkgdown updates and expanded tests.
Reviewed changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
R/conditional_effects.R |
New conditional_effects.bmmfit() implementation + internal helpers (filtering, softmax path, multinomial path). |
R/helpers-parameters.R |
Adds internal helpers to classify parameters and detect softmax parameters. |
R/model_mixture2p.R |
Updates thetat link from identity to logit. |
R/model_mixture3p.R |
Updates thetat/thetant links from identity to softmax. |
R/reexports.R |
Reexports brms::conditional_effects. |
tests/testthat/test-conditional_effects.R |
Adds unit + integration tests for the new method and helpers. |
tests/testthat/test-helpers-parameters.R |
Adds tests for .is_softmax_param() / .get_parameter_info(). |
tests/testthat/test-update.R / tests/testthat/test-summary.R |
Switch test skipping + use system.file() fixture path. |
man/conditional_effects.bmmfit.Rd |
New documentation page for the method. |
man/mixture2p.Rd / man/mixture3p.Rd |
Update documented default links to match model objects. |
vignettes/articles/bmm_conditional_effects.Rmd |
New vignette demonstrating usage and scale behavior. |
_pkgdown.yml |
Adds reference + article entry for conditional effects. |
NEWS.md |
Announces the new conditional_effects() method feature. |
NAMESPACE |
Registers S3 method and exports conditional_effects. |
.Rbuildignore / DESCRIPTION |
Minor build ignore + formatting update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…enpopov/bmm into 203-conditional_effects-bmmfit
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
conditional_effects()S3 method forbmmfitobjects, providing an intuitive interface to visualize predictor effects on model parameters ([feature-request] Adapt S3 methodconditional_effectstobmmfitobjects. #203).get_parameter_info(),.is_softmax_param(),link_transform()) tohelpers-parameters.RKey changes
conditional_effects.bmmfit()par(e.g.,"kappa","thetat") and automatically routes to the correct brmsdpar/nlparscale = "native"(default) to show parameters on their natural scale via inverse link transformations, orscale = "sampling"to show on the MCMC sampling scalethetat,thetantinmixture3p) correctlypar = NULL)Link corrections in mixture model objects
mixture2p:thetatlink changed from"identity"to"logit"— the mixing weight is estimated on the logit scale, and the link specification now reflects thismixture3p:thetatandthetantlinks changed from"identity"to"softmax"— these weights go through a softmax transformation, which is now explicitly declaredThese link corrections are necessary for
conditional_effects()to apply the correct inverse transformations when displaying parameters on their natural scale.Shared helpers (
helpers-parameters.R)link_transform(): forward/inverse link transformations for all brms link functions.get_parameter_info(): classifies a parameter asdpar/nlpar, retrieves its link, and detects softmax.is_softmax_param(): identifies parameters subject to softmax transformationTest plan
link_transform()round-trips across all supported links.is_softmax_param()and.get_parameter_info()conditional_effects.bmmfit()with SDM, mixture2p, and mixture3p models