TuringLang / JuliaBUGS.jl

A domain specific language (DSL) for probabilistic graphical models
https://turinglang.org/JuliaBUGS.jl/
MIT License
22 stars 4 forks source link

Add examples from BUGS volume 2 #186

Closed sunxd3 closed 4 months ago

sunxd3 commented 6 months ago

Fix https://github.com/TuringLang/JuliaBUGS.jl/issues/133 (also #188, which seems to be a numerical thing, fixed by using approximately equality test)

coveralls commented 6 months ago

Pull Request Test Coverage Report for Build 9747173277

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Files with Coverage Reduction New Missed Lines %
src/parser/bugs_parser.jl 1 89.06%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 9237944383: 0.05%
Covered Lines: 1436
Relevant Lines: 1738

💛 - Coveralls
yebai commented 4 months ago

@sunxd3 looks good; do we cover all BUGS models in Vol 1 and Vol 2?

sunxd3 commented 4 months ago

Other than the last four examples from Vol 2, all examples from Vol 1 and 2 are here. I didn't include those examples because either they are not examples on doing inferences (https://www.multibugs.org/examples/latest/Stagnant.html) or they are not very illustrative.

I tried doing HMC (or NUTS) on pretty much all the examples, the results are here. Most examples actually just work. The biggest failure mode is discrete random variable, for instance

a ~ dcat() # Categorical
b ~ dnorm(c[a], 1)

the issue here is a is casted into a float (TrackedReal), but the conversion back to Int is not defined for TrackedReal). MH with individual proposal should work, although with LogDensityProblems interface, it is not straightforward to do.