StatisticalRethinkingJulia / TuringModels.jl

Implementations of the models from the Statistical Rethinking book with Turing.jl
https://statisticalrethinkingjulia.github.io/TuringModels.jl/
MIT License
164 stars 17 forks source link

Go through the models and update their implementation #18

Closed trappmartin closed 4 years ago

trappmartin commented 4 years ago

Some of the models seem to use some older syntax and should be adjusted. I'll have a look and update the implementations accordingly.

goedman commented 4 years ago

Thanks Martin! That would be really great.

torkar commented 4 years ago

Indeed! I had it on my todo list, but since all went south we've been having a lot to do at the university with adapting to distance education... :(

karajan9 commented 4 years ago

Hi there! I'm a beginner both to Turing and Bayes in general but I got a copy of the book (2nd edition) just the other day and my plan was to work through it with Turing and this repo. If I can be of any help, with feedback, testdriving stuff, showing pain points, writing some parts, or what have you, I'd be happy to help!

trappmartin commented 4 years ago

That would be superb.

torkar commented 4 years ago

Sounds terrific. @goedman @trappmartin how should we handle the 2nd edition?

R

trappmartin commented 4 years ago

I don't know any of the two books and can't tell how they differ. So I don't have much of an opinion on that. I think I can mostly be of help in terms of improving Turing models.

goedman commented 4 years ago

From the modeling point of view I don't think a lot of changes are required for the 2nd edition. Currently StatisticalRethinking.jl v2.2 is in sync with the 2nd edition up to chapter 7.

Simulating priors, how results are used, and particularly how models are reviewed, all have evolved, but the existing set of models in TuringModels.jl (and DynamicHMCModels.jl), which were intended as a basis to switch from Stan to Turing or DynamicHMC, might still be kind of sufficient as ultimately the book is not about Stan, or even mcmc, but it's rethinking regression modeling.

Of course a lot more can be done!

The big missing piece in chapters 5 and 6 is the dagitty stuff (which I have been looking into over the last two months).

I haven't seriously worked on chapters 7 and 8 yet and only done some initial work on chapter 9. No work yet on chapters 10 to 13 and the new chapters 14 to 16.

Also, the current versions of the graphics, e.g. plotcoef(), plotbounds(), and supporting functions such as link() and precis(), are 'working' but I consider them first generation at best (and biased towards how I like to work in Julia, e.g. DataFrames.jl and Particles as in MonteCarloMeasurements.jl).

Someone taking a fresh and in depth look at e.g "Statistical Rethinking 2nd edition in Turing" no doubt would improve all of the above tremendously!

goedman commented 4 years ago

Seems all models are running fine! I must say, I'm pretty impressed with how they run. Several of these took almost an hour to run about a year or so ago. I've always liked the Turing model formulation (and having such a model would help on many places), I definitely need to reconsider what a StatisticalRethinking v3 could look like.

I'll register TuringModels.jl version 1.0.1 next.

Martin, is what Chris and I mention in #1 still true as far as you know?

Thanks a lot Martin & Richard.

goedman commented 4 years ago

Just as an FYI, on Julia 1.5-DEV I get:

WARNING: could not import Compiler.just_construct_ssa into Wrap
763ERROR: LoadError: LoadError: InitError: Evaluation into the closed module `AdvancedHMC` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `AdvancedHMC` with `include` during precompilation - don't do this.
764Stacktrace:
765 [1] include(::Function, ::Module, ::String) at ./Base.jl:380
766 [2] include at ./Base.jl:368 [inlined]
767 [3] include at /home/travis/.julia/packages/AdvancedHMC/WJCQA/src/AdvancedHMC.jl:1 [inlined]
768 [4] __init__() at /home/travis/.julia/packages/AdvancedHMC/WJCQA/src/AdvancedHMC.jl:89
769
...
trappmartin commented 4 years ago

Oh, yeah I'm not sure we test against Julia 1.5 atm.

trappmartin commented 4 years ago

I'll close this for now. Feel free to re-open if necessary.

goedman commented 4 years ago

Thanks a lot Martin!