Hotfix/issue 80 sdm likelihood evaluation explodes for extremely high kappa #91
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
Set
init=1
as an additional argument to the output list of configure_args from sdmSimple(). By default stan samples initial values for parameters uniformly on [-2,2], which causes sampling to fail if random effect sds on log(kappa) are initialized close to 2, because some subjects get native kappa value of > exp(15), causing the numerical integration to fail. Setting init to 1 means that Stan will sample in the range [-1,1].I tested it with a bunch of seeds and so far it seems to have solved the problem. I am working on a custom function to easily set inits for bmmmodels for any model formula, but for now this hotfix should help with the sampling failure (which is rare though).
Added a function combine_args() to ensure that if a user provides their own inits, or any other argument they want to overwrite (except for family), the fit_model function will replace the default bmm arguments with the user ones.
Tests
[x] Confirm that all tests passed
[x] Confirm that devtools::check() produces no errors
Release notes