Generate Stan code modularly#5
Open
wpetry wants to merge 18 commits into
Open
Conversation
Author
|
To do before submitting for review:
|
Author
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.
This PR aims to generalize the types of models that can be fit by giving the user control of how sampling effort, animal preference, and relative abundances are modeled. This is achieved by substituting the current static Stan models with a new internal function
stancodethat composes the Stan code through a series of switches that respond to user-specified options. A modular approach to constructing the code will also enable future functionality to be added without needing to edit many individual Stan files by hand.Additional new features to accommodate this change are:
get_posteriorto userlangin place of current embedded functions. This dependency is already present viadplyr. This approach should be more readily extensible if/when new modeling options are added.There are several major changes that will impact backwards compatibility with existing code that uses the package:
fit_modelloses an argument to accept a file path to Stan code. I think this was a non-functional placeholder, and it's not clear when a user would want to use this function instead of the$sample()method fromcmdstanr.