Skip to content

chain_type argument is not respected in sample calls #381

@yebai

Description

@yebai
julia> using JuliaBUGS, Random, AbstractMCMC, MCMCChains

julia> model = JuliaBUGS.@bugs"""
       model {
         for (i in 1:N) {
           y[i] ~ dnorm(mu, tau)
         }
         mu ~ dnorm(0, 0.001)
         tau ~ dgamma(0.1, 0.1)
       }
       """
quote
    for i = 1:N
        y[i] ~ dnorm(mu, tau)
    end
    mu ~ dnorm(0, 0.001)
    tau ~ dgamma(0.1, 0.1)
end

julia> posterior = compile(model, (; N = 10, y = randn(10)))
BUGSModel (parameters are in transformed (unconstrained) space, with dimension 2):

  Model parameters:
    mu
    tau

  Variable sizes and types:
    N: type = Int64
    y: size = (10,), type = Vector{Float64}
    mu: type = Float64
    tau: type = Float64


julia> chain = AbstractMCMC.sample(
          Random.MersenneTwister(123), posterior, JuliaBUGS.IndependentMH(), 2; 
          chain_type=Chains, progress=false
       )
2-element Vector{@NamedTuple{N::Int64, mu::Float64, y::Vector{Float64}, tau::Float64}}:
 (N = 10, mu = -16.716896707057163, y = [-0.561760534372701, 1.5181161412988122, -0.005971601196035465, 0.569676203953282, 0.5526837027372513, -0.9996112240832798, 1.2464363157303342, -0.34197399574631904, 0.22211367519968409, -0.13973334796804815], tau = 3.001539274927197)
 (N = 10, mu = 22.214624166312408, y = [-0.561760534372701, 1.5181161412988122, -0.005971601196035465, 0.569676203953282, 0.5526837027372513, -0.9996112240832798, 1.2464363157303342, -0.34197399574631904, 0.22211367519968409, -0.13973334796804815], tau = 0.03649517193786087)

Here, the chain_type argument is not respected: the returned chain is a NamedTuple instead of `MCMCChains.Chains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions