Add Stan support as alternative Bayesian modeling backend #175
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.
Implements Stan/cmdstanr support alongside existing JAGS implementation, allowing users to choose their preferred Bayesian MCMC backend.
Changes
Stan Model Files
inst/extdata/model.stan- Main antibody dynamics model with:step()inst/extdata/model.dobson.stan- Simple Bernoulli exampleR Functions
run_mod_stan()- Stan equivalent ofrun_mod(), returns samesr_modeloutput formatprep_data_stan()- Handles Stan array padding requirements (no ragged arrays)prep_priors_stan()- Prior specification interface matchingprep_priors()Dependencies
cmdstanrto Suggests (not Imports) - Stan support is optionalUsage
Both return compatible outputs for existing analysis/plotting functions.
Installation (Stan)
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cloud.r-project.org/opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R -e install.packages('cmdstanr',~+~repos~+~=~+~c('REDACTED',~+~'REDACTED'))(dns block)stan-dev.r-universe.dev/opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R -e install.packages('cmdstanr',~+~repos~+~=~+~c('REDACTED',~+~'REDACTED'))(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.