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 m8_4(y) = begin
    # 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     = 25.69 seconds
Compute duration  = 25.69 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

          α₁   -2952.0314   29.8656     0.6678    2.6118   107.5325    1.0083        4.1853
          α₂    2951.9869   29.8670     0.6678    2.6119   107.5030    1.0083        4.1841
           σ       1.0297    0.0820     0.0018    0.0084    78.8378    1.0181        3.0685

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

          α₁   -2995.4647   -2977.6737   -2955.9139   -2927.3799   -2896.6027
          α₂    2896.5861    2927.3468    2955.8696    2977.6266    2995.4430
           σ       0.8847       0.9709       1.0246       1.0828       1.2011

Output

using StatsPlots

StatsPlots.plot(chns)

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
""";