brian-j-smith / Mamba.jl

Markov chain Monte Carlo (MCMC) for Bayesian analysis in julia
Other
253 stars 52 forks source link

ABC Sampler #78

Closed bdeonovic closed 8 years ago

bdeonovic commented 8 years ago

Updated to new Sampler notation. The line results look to be in line with the other Bayesian linear regression results. I've tweaked the sampler parameters so that the sampling is reasonably quick (about a minute per chain). If you decrease the parameter n in the example to about 50 it takes about 20 seconds per chain, but the results a a bit nosier.

bdeonovic commented 8 years ago

I just remembered our discussion about the terminal nodes. I'll make those changes and push commits.

brian-j-smith commented 8 years ago

This is coming along nicely. To accommodate the general case of multiple terminal nodes, you might create a Vector{Vector{Float64}} of their node-specific unlisted values. Also, the mu node in the line model specification could be removed to further simplify the example for this specific application.

bdeonovic commented 8 years ago

Brian, I'm unable to figure out why I am getting this error when I run the example:

ERROR: UndefVarError: terminals not defined
 [inlined code] from /Users/bdeonovic/.julia/v0.4/Mamba/src/samplers/abc.jl:37
 in anonymous at no file:0
 in anonymous at no file
 in simulate! at /Users/bdeonovic/.julia/v0.4/Mamba/src/model/simulation.jl:129
 in simulate! at /Users/bdeonovic/.julia/v0.4/Mamba/src/model/simulation.jl:124
 in mcmc_worker! at /Users/bdeonovic/.julia/v0.4/Mamba/src/model/mcmc.jl:75
 in map at abstractarray.jl:1308
 in mcmc_master! at /Users/bdeonovic/.julia/v0.4/Mamba/src/model/mcmc.jl:53
 in mcmc at /Users/bdeonovic/.julia/v0.4/Mamba/src/model/mcmc.jl:33

This error doesn't make sense to me because (1) the variable terminals is defined on line 36, (2) this code works before the above 2 commit

brian-j-smith commented 8 years ago

See comment added to the commit.

bdeonovic commented 8 years ago

Thanks that fixed it. I've squashed commits. I can rebase when you update docs.

brian-j-smith commented 8 years ago

The documentation changes are in master and can be rebased against now. See the above diff comment on how the changes affect the rebase.

bdeonovic commented 8 years ago

Great, I'll get that in soon. Also, I've got another example for the ABC sampler working for a distribution whose pdf is intractable, but for which sampling is very easy. Do you think it should go in a separate PR?

brian-j-smith commented 8 years ago

A separate PR would be preferable.

bdeonovic commented 8 years ago

Okay, I will do that. I've rebased the ABC sampler onto your most recent commit.

bdeonovic commented 8 years ago

I just remembered what I wanted to say in the hallway: I was wondering if the use of map calls in the ABC function could be slowing it down as compared to using for-loops. I'm not always 100% clear on Julia best practices or how it optimizes code so I was just wondering what you thought.

brian-j-smith commented 8 years ago

I just pushed up a new sampler/abc branch with revisions to the ABC sampler, including consolidation of the map calls. The code should be fairly well optimized now. Have a look at the revisions and let me know if you see any remaining issues with the sampler or if it looks ready to be merged into master.

brian-j-smith commented 8 years ago

This is merged into master and will be in the next package release (0.8.0).