Add Stan support as alternative Bayesian modeling backend#175
Draft
Add Stan support as alternative Bayesian modeling backend#175
Conversation
Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Convert JAGS model to STAN
Add Stan support as alternative Bayesian modeling backend
Jan 9, 2026
d-morrison
requested changes
Jan 10, 2026
Collaborator
d-morrison
left a comment
There was a problem hiding this comment.
fix failing workflow checks
d-morrison
requested changes
Jan 10, 2026
Collaborator
d-morrison
left a comment
There was a problem hiding this comment.
address workflow check failures
d-morrison
requested changes
Jan 21, 2026
…s.yml Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
d-morrison
requested changes
Jan 27, 2026
Collaborator
d-morrison
left a comment
There was a problem hiding this comment.
fix failing workflows
Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Contributor
Author
Fixed in d5ad3ce. The R-CMD-check workflow was failing because the |
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.
Convert JAGS Model to Stan ✅
This task successfully adds Stan support to the serodynamics package as an alternative to JAGS for Bayesian MCMC modeling. Both modeling backends can coexist, allowing users to choose their preferred framework.
Completed Work
Research Stan ecosystem and best practices
Create Stan model files
model.jagstoinst/extdata/model.stan(117 lines)model.dobson.jagstoinst/extdata/model.dobson.stan(19 lines)Create R infrastructure for Stan
prep_data_stan()function (75 lines) - converts data to Stan format with proper paddingprep_priors_stan()function (78 lines) - prepares Stan-compatible prior specificationsrun_mod_stan()function (197 lines) - complete Stan equivalent ofrun_mod()Update dependencies and documentation
Update README and documentation
Package validation
CI/Build improvements
*.knit.*pattern to.gitignoreto exclude intermediate knit filesREADME.knit.mdfrom git trackingcopilot-setup-steps.ymlworkflow\dontrun{}Implementation Details
Stan Model Conversion:
dnorm(mu, tau)tonormal(mu, sigma)wheresigma = 1/sqrt(tau)dwish(omega, df)toinv_wishart(df, omega_inv)whereomega_inv = inverse(omega)dgamma(a, b)parameters (same in both)Data Preparation:
prep_data_stan()handles thisnsmpl[subj]to ignore paddingIntegration:
sr_modelclass)CI Environment:
Example Code Fix:
run_mod_stan()examples in\dontrun{}to prevent execution during R CMD checkWhat Users Can Do Now
Use JAGS (existing functionality):
Use Stan (new functionality):
Both produce compatible outputs that work with the same analysis and visualization functions.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.