7.1 The problem with parameters

Code 7.1

Code 7.2

Code 7.3

To match results from the book, the model was optimized using MAP estimation, not the MCMC I used before. The reason for that is the MCMC producing different estimation for log_σ value, which makes all the values very different.

If you want, you can experiment with NUTS sampler for models in 7.1 and 7.2.

In addition, you can also check this discussion: https://github.com/StatisticalRethinkingJulia/StatisticalRethinkingTuring.jl/issues/7

Code 7.4

Code 7.5

Code 7.6

Code 7.7

Code 7.8

Implemented the sample in a general way

Code 7.9

Code 7.10

Code 7.11

7.2 Entropy and accuracy

Code 7.12

Code 7.13

Code 7.14

Code 7.15

Code 7.16

Code 7.17

Code 7.18

Hm, something is different

7.3 Golem taming: regularization

No code pieces in this section

7.4 Predicting predictive accuracy

Code 7.19

Code 7.20

Code 7.21

Code 7.22

Code 7.23

Code 7.24

7.5 Model comparison

Data and models from chapter 6

Code 7.25

Code 7.26

Code 7.27

Code 7.28

Code 7.29

Code 7.30

Code 7.31

Current version of StatisticalRethinking.compare doesn't calculate pairwise error. You should use above logic to get values not returned in compare result.

Code 7.32

Code 7.33

Code 7.34

Code 7.35

Visualize PSIS