TuringModels

Non-identifiable model

  1. Data
  2. Model
  3. Output
  4. Original output

Data

using Distributions
using Random

Random.seed!(1)
y = rand(Normal(0,1), 100);

Model

using Turing

@model function m8_4(y)
    # Can't really set a Uniform[-Inf,Inf] on σ
    α₁ ~ Uniform(-3000, 1000)
    α₂ ~ Uniform(-1000, 3000)
    σ ~ truncated(Cauchy(0,1), 0, Inf)

    y ~ Normal(α₁ + α₂, σ)
end

chns = sample(m8_4(y), NUTS(), 2000)
Chains MCMC chain (2000×15×1 Array{Float64, 3}):

Iterations        = 1001:1:3000
Number of chains  = 1
Samples per chain = 2000
Wall duration     = 33.9 seconds
Compute duration  = 33.9 seconds
parameters        = α₁, α₂, σ
internals         = lp, n_steps, is_accept, acceptance_rate, log_density, hamiltonian_energy, hamiltonian_energy_error, max_hamiltonian_energy_error, tree_depth, numerical_error, step_size, nom_step_size

Summary Statistics
  parameters         mean        std   naive_se      mcse       ess      rhat   ess_per_sec
      Symbol      Float64    Float64    Float64   Float64   Float64   Float64       Float64

          α₁   -1710.0216   558.0246    12.4778   82.7690    6.0734    1.0338        0.1791
          α₂    1710.0292   558.0239    12.4778   82.7690    6.0734    1.0338        0.1791
           σ       1.0841     0.1126     0.0025    0.0165    7.4392    1.1503        0.2194

Quantiles
  parameters         2.5%        25.0%        50.0%        75.0%       97.5%
      Symbol      Float64      Float64      Float64      Float64     Float64

          α₁   -2564.0394   -2196.4236   -1688.2252   -1391.0186   -651.0298
          α₂     650.8972    1391.0622    1688.2500    2196.4034   2564.1365
           σ       0.9320       1.0136       1.0525       1.1278      1.3738

Output

using StatsPlots

StatsPlots.plot(chns)
"/home/runner/work/TuringModels.jl/TuringModels.jl/__site/assets/models/non-identifiable/code/output/chns.svg"

Original output

"""
         mean      sd     5.5%   94.5% n_eff Rhat
 a1    -861.15 558.17 -1841.89  -31.04     7 1.43
 a2     861.26 558.17    31.31 1842.00     7 1.43
 sigma    0.97   0.07     0.89    1.09     9 1.17
""";