Git Product home page Git Product logo

sr2turingpluto.jl's Introduction

Purpose of SR2TuringPluto.jl

As stated many times by the author in his online lectures, StatisticalRethinking is a hands-on course. This project is intended to assist with the hands-on aspect of learning the key ideas in Statistical Rethinking.

SR2TuringPluto is a Julia project that uses Pluto notebooks for this purpose. Max Lapan has a version using Jupyter. Many of the Pluto notebooks have been derived from Max Lapan's work!

This Julia project uses Turing as the underlying mcmc implementation. A companion project ( SR2StanPluto.jl ) uses Stan.

Each notebook demonstrates Julia versions of code snippets and mcmc models contained in the R package "rethinking" associated with the book Statistical Rethinking by Richard McElreath.

Installation

To (locally) reproduce and use this project, do the following:

  1. Download this project from Github and move to the downloaded directory, e.g.:
$ git clone https://github.com/StatisticalRethinkingJulia/SR2TuringPluto.jl SR2TuringPluto
$ cd SR2TuringPluto

If you want a specific tagged version, use:

$ git tag -l # To see available tags, followed by:
$ git checkout tags/<tag_name> # or simply:
$ git checkout v4.5.0

The next step assumes your base Julia setup includes at least Pkg and Pluto.

  1. Start a Pluto notebook server in the Julia REPL:
$ julia

julia> using Pluto
julia> Pluto.run()
  1. A Pluto page should open in a browser.

Usage

Select a notebook in the open a file entry box, e.g. type ./ and step to ./notebooks/Chapter_00.jl.

All "rethinking" data files are stored and maintained in StatisticalRethinking.jl and can be accessed via sr_datadir(...).

This leads to a typical set of opening lines in each notebook:

using Pkg

# Note: Below sequence is important. First activate the project
# followed by `using` or `import` statements. Pretty much all
# scripts use StatisticalRethinking. If mcmc sampling is
# needed, it must be loaded before StatisticalRethinking:

using Turing
# more using lines, e.g.
using CSV, DataFrames, Distributions
using StatisticalRethinking
using StatisticalRethinkingPlots, StatsPlots, Plots

# To access e.g. the Howell1.csv data file:
df = CSV.read(sr_datadir("Howell1.csv"), DataFrame)
df = df[df.age .>= 18, :]

Naming of models and results:

  1. ppl5_1 : Turing model
  2. m5_1t : The instantiated Turing model (includes data)

Chain(s):

  1. chns5_1t : MCMCChains object (4000 samples from 4 chains)

Results as a DataFrame:

  1. prior5_1t_df : Prior samples (DataFrame)
  2. post5_1t_df : Posterior samples (DataFrame)
  3. quap5_1t_df : MAP approximation to posterior samples (DataFrame)
  4. pred5_1t_df : Posterior predictions (DataFrame)

As before, the t at the end of the model number indicates Turing.

Note: Naming is not yet consistent through all notebooks. Work in progress!

Status

SR2TuringPluto.jl is compatible with the 2nd edition of the book.

StructuralCausalModels.jl and ParetoSmoothedImportanceSampling.jl are included as experimental dependencies in the StatisticalRethinking.jl package. Definitely work in progress!

Max Lapan added a package Dagitty.jl which covers options similar as available in StructuralCausalModels.jl. There is also a new package, ParetoSmooth.jl which overlaps with ParetoSmoothedImportanceSampling.jl. As terminology differs from the terminology used in the Statistical Rethinking book, I have not used this package in the notebooks (yet?).

Any feedback is appreciated. Please open an issue.

Acknowledgements

Of course, without the excellent textbook by Richard McElreath, this package would not have been possible. The author has also been supportive of this work and gave permission to use the datasets.

This repository is derived from work by Max Lapan, Karajan, previous and current Stan versions of StatisticalRethinking.jl. It has been improved through comments and suggestions by many other contributors.

Versions

Version 5.0.0 (Under development, will take time)

  1. Complete overhaul. Likely using Makie.jl, Graphs.jl and more.

Version 4.5.0

  1. Adapted Max Lapan's chapters 5 to 14 to an (initial) Pluto format.

Version 4.0.5

  1. Minor updates to chapters 1-5.

Version 4.0.4

  1. Package updates.

Version 4.0.0-4.0.3

  1. Switch to StatisticalRethinking v4.
  2. Switch to notebooks under development by Max Lapan. Notebooks are being converted to Pluto (vs. Jupyter notebooks).

versions 2 & 3

  1. Many additions for 2nd edition of Statistical Rethinking book.
  2. Version 3 uses many ideas proposed in Karajan's scripts

Version 1.0.0 (in preparation, expected late Nov 2020)

  1. Initial version

sr2turingpluto.jl's People

Contributors

goedman avatar pitmonticone avatar thatcherc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.