m8.1t.jl

m8.1stan

m8.1stan is the first model in the Statistical Rethinking book (pp. 249) using Stan.

Here we will use Turing's NUTS support, which is currently (2018) the originalNUTS by Hoffman & Gelman and not the one that's in Stan 2.18.2, i.e., Appendix A.5.

The StatisticalRethinking pkg uses, e.g., Turing, CSV, DataFrames

using StatisticalRethinking
loaded


┌ Warning: Package Turing does not have CmdStan in its dependencies:
│ - If you have Turing checked out for development and have
│   added CmdStan as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with Turing
│ Loading CmdStan into Turing from project dependency, future warnings for Turing are suppressed.
└ @ nothing nothing:840
WARNING: using CmdStan.Sample in module Turing conflicts with an existing identifier.

Read in rugged data as a DataFrame

d = CSV.read(joinpath(dirname(Base.pathof(StatisticalRethinking)), "..", "data",
    "rugged.csv"), delim=';');
# Show size of the DataFrame (should be 234x51)
size(d)
(234, 51)

Apply log() to each element in rgdppc_2000 column and add it as a new column

d = hcat(d, map(log, d[Symbol("rgdppc_2000")]));

Rename our col x1 => log_gdp

rename!(d, :x1 => :log_gdp);

Now we need to drop every row where rgdppc_2000 == missing

When this (https://github.com/JuliaData/DataFrames.jl/pull/1546) hits DataFrame it'll be conceptually easier: i.e., completecases!(d, :rgdppc_2000)

notisnan(e) = !ismissing(e)
dd = d[map(notisnan, d[:rgdppc_2000]), :];

Updated DataFrame dd size (should equal 170 x 52)

size(dd)
(170, 52)

Define the Turing model

@model m8_1stan(y, x₁, x₂) = begin
    σ ~ Truncated(Cauchy(0, 2), 0, Inf)
    βR ~ Normal(0, 10)
    βA ~ Normal(0, 10)
    βAR ~ Normal(0, 10)
    α ~ Normal(0, 100)

    for i ∈ 1:length(y)
        y[i] ~ Normal(α + βR * x₁[i] + βA * x₂[i] + βAR * x₁[i] * x₂[i], σ)
    end
end;

Test to see that the model is sane. Use 2000 for now, as in the book. Need to set the same stepsize and adapt_delta as in Stan...

posterior = sample(m8_1stan(dd[:,:log_gdp], dd[:,:rugged], dd[:,:cont_africa]),
    Turing.NUTS(2000, 1000, 0.95));
# Describe the posterior samples
describe(posterior)
┌ Warning: Indexing with colon as row will create a copy in the future. Use `df[col_inds]` to get the columns without copying
│   caller = top-level scope at In[8]:1
└ @ Core In[8]:1
┌ Warning: Indexing with colon as row will create a copy in the future. Use `df[col_inds]` to get the columns without copying
│   caller = top-level scope at In[8]:1
└ @ Core In[8]:1
┌ Warning: Indexing with colon as row will create a copy in the future. Use `df[col_inds]` to get the columns without copying
│   caller = top-level scope at In[8]:1
└ @ Core In[8]:1
┌ Info: [Turing] looking for good initial eps...
└ @ Turing /Users/rob/.julia/packages/Turing/orJH9/src/samplers/support/hmc_core.jl:246
[NUTS{Union{}}] found initial ϵ: 0.05
└ @ Turing /Users/rob/.julia/packages/Turing/orJH9/src/samplers/support/hmc_core.jl:291
[NUTS] Sampling...  1%  ETA: 0:06:54
  ϵ:         0.021702349971125082
  α:         0.9890516933991319
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  2%  ETA: 0:05:49
  ϵ:         0.025964213600878867
  α:         0.8596042698404098
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  3%  ETA: 0:04:25
  ϵ:         0.014815766991558857
  α:         0.9934963906380034
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  4%  ETA: 0:03:49
  ϵ:         0.032734674808041646
  α:         0.8267264305201034
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  5%  ETA: 0:03:11
  ϵ:         0.03183906486749323
  α:         0.9980435182012655
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  6%  ETA: 0:02:52
  ϵ:         0.02332219042746582
  α:         0.9938986598752901
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  7%  ETA: 0:02:42
  ϵ:         0.022765193972566565
  α:         0.9963929753051147
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  8%  ETA: 0:02:32
  ϵ:         0.018115226291014586
  α:         0.9831564890831901
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...  9%  ETA: 0:02:24
  ϵ:         0.0264916665322655
  α:         0.9887844525209211
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 10%  ETA: 0:02:16
  ϵ:         0.021575607716437604
  α:         0.9749267632446936
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 11%  ETA: 0:02:10
  ϵ:         0.03141462283517077
  α:         0.8714611472530431
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 12%  ETA: 0:02:04
  ϵ:         0.02939689779238441
  α:         0.9984025534187178
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 13%  ETA: 0:02:03
  ϵ:         0.01909107851666875
  α:         0.9992739975281155
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 14%  ETA: 0:02:02
  ϵ:         0.021149241662058213
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 15%  ETA: 0:01:58
  ϵ:         0.023888285400989993
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 16%  ETA: 0:01:57
  ϵ:         0.01889749833742631
  α:         0.9178221360475471
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 16%  ETA: 0:01:54
  ϵ:         0.03289091879046056
  α:         0.9983176872334326
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 18%  ETA: 0:01:51
  ϵ:         0.03143636930148497
  α:         0.973450644644926
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 19%  ETA: 0:01:48
  ϵ:         0.03333568334968122
  α:         0.8802416912910938
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 19%  ETA: 0:01:47
  ϵ:         0.024860129757923958
  α:         0.9465574509975048
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 20%  ETA: 0:01:45
  ϵ:         0.024147271950740724
  α:         0.9963454219465105
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 21%  ETA: 0:01:42
  ϵ:         0.02841750041302116
  α:         0.9915183507724583
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 23%  ETA: 0:01:38
  ϵ:         0.03477889821030197
  α:         0.9620996967069368
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 24%  ETA: 0:01:35
  ϵ:         0.02292329764909516
  α:         0.9531273994262867
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 25%  ETA: 0:01:34
  ϵ:         0.03465171740982106
  α:         0.9696570042137486
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 26%  ETA: 0:01:32
  ϵ:         0.03154099794490125
  α:         0.9666588241056846
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 27%  ETA: 0:01:30
  ϵ:         0.025445032131723687
  α:         0.9987618606606394
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 28%  ETA: 0:01:29
  ϵ:         0.02700948014435288
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 29%  ETA: 0:01:26
  ϵ:         0.04045178285341591
  α:         0.9962842848999183
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 30%  ETA: 0:01:24
  ϵ:         0.015560536869733648
  α:         0.9822753019048962
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 31%  ETA: 0:01:23
  ϵ:         0.022521210797718835
  α:         0.9747560489912214
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 32%  ETA: 0:01:21
  ϵ:         0.036886036835501936
  α:         0.9641170285183496
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 33%  ETA: 0:01:18
  ϵ:         0.03218803022030199
  α:         0.8559107831132022
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 34%  ETA: 0:01:17
  ϵ:         0.03217185677378528
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 36%  ETA: 0:01:14
  ϵ:         0.029934090465140267
  α:         0.9637935308868608
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 37%  ETA: 0:01:13
  ϵ:         0.03766209842729723
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 38%  ETA: 0:01:11
  ϵ:         0.022525648837685045
  α:         0.979910303228714
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 39%  ETA: 0:01:10
  ϵ:         0.01786061046273
  α:         0.9771913428474581
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 40%  ETA: 0:01:09
  ϵ:         0.028067342663153656
  α:         0.9753760022954534
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 40%  ETA: 0:01:08
  ϵ:         0.028986812476833282
  α:         0.9375335119964464
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 41%  ETA: 0:01:07
  ϵ:         0.032117279642967206
  α:         0.9940669026916351
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 42%  ETA: 0:01:06
  ϵ:         0.030737127864859708
  α:         0.9821912777159816
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 43%  ETA: 0:01:05
  ϵ:         0.026438391658241963
  α:         0.9980480594684609
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 44%  ETA: 0:01:03
  ϵ:         0.02780498401755003
  α:         0.9379581388525683
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 45%  ETA: 0:01:02
  ϵ:         0.021497580222665725
  α:         0.997838993180469
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 46%  ETA: 0:01:01
  ϵ:         0.030820042201476643
  α:         0.9780183694318911
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 47%  ETA: 0:00:59
  ϵ:         0.02581329680132846
  α:         0.9602252978375723
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 48%  ETA: 0:00:58
  ϵ:         0.04447510506264669
  α:         0.9603561420806969
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 50%  ETA: 0:00:57
  ϵ:         0.028028277925480596
  α:         0.936555913265008
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]┌ Info:  Adapted ϵ = 0.028862387932864265, std = [1.0, 1.0, 1.0, 1.0, 1.0]; 1000 iterations is used for adaption.
└ @ Turing /Users/rob/.julia/packages/Turing/orJH9/src/samplers/adapt/adapt.jl:91



[NUTS] Sampling... 51%  ETA: 0:00:55
  ϵ:         0.028862387932864265
  α:         0.9731170875091677
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 52%  ETA: 0:00:54
  ϵ:         0.028862387932864265
  α:         0.9323017998991567
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 53%  ETA: 0:00:53
  ϵ:         0.028862387932864265
  α:         0.9903549704526096
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 54%  ETA: 0:00:51
  ϵ:         0.028862387932864265
  α:         0.9978152996666327
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 55%  ETA: 0:00:50
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 56%  ETA: 0:00:49
  ϵ:         0.028862387932864265
  α:         0.9745595306250021
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 57%  ETA: 0:00:48
  ϵ:         0.028862387932864265
  α:         0.9364723452724012
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 58%  ETA: 0:00:47
  ϵ:         0.028862387932864265
  α:         0.9882822029392492
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 59%  ETA: 0:00:46
  ϵ:         0.028862387932864265
  α:         0.9764526530232573
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 60%  ETA: 0:00:44
  ϵ:         0.028862387932864265
  α:         0.9945875964420767
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 61%  ETA: 0:00:42
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 62%  ETA: 0:00:41
  ϵ:         0.028862387932864265
  α:         0.9962157248944833
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 63%  ETA: 0:00:40
  ϵ:         0.028862387932864265
  α:         0.9890323655917073
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 65%  ETA: 0:00:38
  ϵ:         0.028862387932864265
  α:         0.8324021795495518
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 66%  ETA: 0:00:37
  ϵ:         0.028862387932864265
  α:         0.9657150103723464
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 67%  ETA: 0:00:36
  ϵ:         0.028862387932864265
  α:         0.9234381416818382
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 68%  ETA: 0:00:35
  ϵ:         0.028862387932864265
  α:         0.9494730649956734
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 69%  ETA: 0:00:34
  ϵ:         0.028862387932864265
  α:         0.8784878588473566
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 69%  ETA: 0:00:33
  ϵ:         0.028862387932864265
  α:         0.9935813628621196
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 70%  ETA: 0:00:32
  ϵ:         0.028862387932864265
  α:         0.9727677401574897
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 71%  ETA: 0:00:31
  ϵ:         0.028862387932864265
  α:         0.9942663653403332
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 73%  ETA: 0:00:29
  ϵ:         0.028862387932864265
  α:         0.9439622157894664
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 74%  ETA: 0:00:28
  ϵ:         0.028862387932864265
  α:         0.999478295756282
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 75%  ETA: 0:00:27
  ϵ:         0.028862387932864265
  α:         0.9729044361179782
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 75%  ETA: 0:00:26
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 76%  ETA: 0:00:26
  ϵ:         0.028862387932864265
  α:         0.9894849332618576
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 77%  ETA: 0:00:25
  ϵ:         0.028862387932864265
  α:         0.9978627128794907
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 78%  ETA: 0:00:24
  ϵ:         0.028862387932864265
  α:         0.9929515657222006
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 79%  ETA: 0:00:23
  ϵ:         0.028862387932864265
  α:         0.9993663615086615
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 80%  ETA: 0:00:22
  ϵ:         0.028862387932864265
  α:         0.99958917121676
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 81%  ETA: 0:00:21
  ϵ:         0.028862387932864265
  α:         0.9948412904815331
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 82%  ETA: 0:00:20
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 82%  ETA: 0:00:19
  ϵ:         0.028862387932864265
  α:         0.9846293914634091
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 83%  ETA: 0:00:18
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 84%  ETA: 0:00:17
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 85%  ETA: 0:00:16
  ϵ:         0.028862387932864265
  α:         0.9867209387222736
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 86%  ETA: 0:00:15
  ϵ:         0.028862387932864265
  α:         0.9757542419609502
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 88%  ETA: 0:00:13
  ϵ:         0.028862387932864265
  α:         0.9098487923015703
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 89%  ETA: 0:00:12
  ϵ:         0.028862387932864265
  α:         0.9116645340587638
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 90%  ETA: 0:00:11
  ϵ:         0.028862387932864265
  α:         0.8741954363453688
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 90%  ETA: 0:00:10
  ϵ:         0.028862387932864265
  α:         0.98152618446337
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 92%  ETA: 0:00:09
  ϵ:         0.028862387932864265
  α:         1.0
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 93%  ETA: 0:00:08
  ϵ:         0.028862387932864265
  α:         0.997082288585899
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 94%  ETA: 0:00:07
  ϵ:         0.028862387932864265
  α:         0.9913409566691967
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 95%  ETA: 0:00:06
  ϵ:         0.028862387932864265
  α:         0.9636173199279039
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 96%  ETA: 0:00:05
  ϵ:         0.028862387932864265
  α:         0.8274183984970295
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 97%  ETA: 0:00:04
  ϵ:         0.028862387932864265
  α:         0.9899779190278849
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 98%  ETA: 0:00:03
  ϵ:         0.028862387932864265
  α:         0.906318260459193
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling... 98%  ETA: 0:00:02
  ϵ:         0.028862387932864265
  α:         0.9917617167298529
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]


[NUTS] Sampling...100%  ETA: 0:00:00
  ϵ:         0.028862387932864265
  α:         0.8337995406437935
4m  pre_cond:  [1.0, 1.0, 1.0, 1.0, 1.0]




[NUTS] Finished with
  Running time        = 107.10928417000004;
  #lf / sample        = 0.0015;
  #evals / sample     = 44.931;
  pre-cond. metric    = [1.0, 1.0, 1.0, 1.0, 1.0].


[NUTS] Sampling...100% Time: 0:01:48


Iterations = 1:2000
Thinning interval = 1
Chains = 1
Samples per chain = 2000

Empirical Posterior Estimates:
              Mean           SD         Naive SE        MCSE         ESS   
       α    9.192198853  0.471485288 0.01054273155 0.03488051527  182.71345
  lf_num    0.001500000  0.067082039 0.00150000000 0.00150000000 2000.00000
      βA   -1.916864926  0.377451668 0.00844007588 0.02969740713  161.54207
      βR   -0.195354050  0.142021349 0.00317569391 0.01008324641  198.38394
       σ    0.968861418  0.295329191 0.00660376148 0.01871696223  248.96714
 elapsed    0.053554642  0.076105161 0.00170176314 0.00239230124 1012.03724
 epsilon    0.029681037  0.018393691 0.00041129543 0.00041492961 1965.11923
eval_num   44.931000000 25.521538227 0.57067894365 0.67314732101 1437.45232
     βAR    0.386290432  0.160630677 0.00359181114 0.00838013229  367.41360
      lp -249.858010884 17.850220615 0.39914306709 1.35731471511  172.95219
  lf_eps    0.029681037  0.018393691 0.00041129543 0.00041492961 1965.11923

Quantiles:
              2.5%           25.0%          50.0%          75.0%          97.5%    
       α    8.948743652    9.126714263    9.221557657    9.318783435    9.501543505
  lf_num    0.000000000    0.000000000    0.000000000    0.000000000    0.000000000
      βA   -2.368320692   -2.097968685   -1.938597291   -1.779472367   -1.451814577
      βR   -0.361073257   -0.254798277   -0.204489451   -0.149987743   -0.042763334
       σ    0.857642577    0.915085102    0.947928480    0.984199708    1.060340022
 elapsed    0.009562707    0.026420479    0.050147139    0.061298654    0.116432655
 epsilon    0.018468817    0.028417477    0.028862388    0.028862388    0.039981894
eval_num   10.000000000   22.000000000   46.000000000   46.000000000   94.000000000
     βAR    0.118640406    0.298877960    0.395536816    0.480566011    0.656950733
      lp -252.744273688 -249.297284956 -248.219714562 -247.399261183 -246.384239328
  lf_eps    0.018468817    0.028417477    0.028862388    0.028862388    0.039981894

Example of a Turing run simulation output

m_08_1t_turing_result = "
        Mean           SD        Naive SE        MCSE         ESS
α    9.2140454953  0.416410339 0.00931121825 0.0303436655  188.324543
βA  -1.9414588557  0.373885658 0.00836033746 0.0583949856   40.994586
βR  -0.1987645549  0.158902372 0.00355316505 0.0128657961  152.541295
σ    0.9722532977  0.440031013 0.00983939257 0.0203736871  466.473854
βAR  0.3951414223  0.187780491 0.00419889943 0.0276680621   46.062071
";

Here's the map2stan output from rethinking

m_08_1_map2stan_result = "
       Mean StdDev lower 0.89 upper 0.89 n_eff Rhat
 a      9.24   0.14       9.03       9.47   291    1
 bR    -0.21   0.08      -0.32      -0.07   306    1
 bA    -1.97   0.23      -2.31      -1.58   351    1
 bAR    0.40   0.13       0.20       0.63   350    1
 sigma  0.95   0.05       0.86       1.03   566    1
";

#-

This notebook was generated using Literate.jl.