Skip to content

Stan log_prob exceptions cause moment_matching to fail #261

@avehtari

Description

@avehtari

Reported in Stan discourse with reproducible example
https://discourse.mc-stan.org/t/add-criterion-with-moment-match-true-failing-even-when-save-pars-all-true-was-set-during-model-fit/30956/13

The moment matching transformed unconstrained parameter values can under- or overflow when constrained or some further quantity in the Stan program can under- or overflow. In this example one of the variables inside the model is 0, while should be positive. This causes an exception, which causes an error in R and moment_matching quits:

Error : Exception: beta_lpdf: Second shape parameter is 0, but must be positive finite! (in 'string', line 226, column 6 to column 111)

brms catches this error, but makes only one guess for the reason

Error: Moment matching failed. Perhaps you did not set 'save_pars = save_pars(all = TRUE)' when fitting your model? If you are running moment matching on another machine than the one used to fit the model, you may need to set recompile = TRUE.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions