Skip to content

"Wrong" order from names(chain, :parameters) #326

@knuesel

Description

@knuesel

Consider this example:

@model function mymodel(x)
    σ ~ LogNormal()
    a ~ Normal()
    c ~ Normal()
    b ~ Normal()
    x .~ Normal(a+b+c, σ)
end

model = mymodel(randn(1000))
ch = sample(model, NUTS(0.65), 100)
plot(ch)

This plots the parameters in the order σ, a, c, b. This matches the order of parameters in the underlying AxisArray. However, retrieving the parameter list with names gives a different order:

julia> names(ch, :parameters)
4-element Vector{Symbol}:
 :a
 :b
 
 :c

My use case: I want to add things on the plots created by plot(ch). To modify the plot for the ith parameter I can do plot!(..., subplot=2i). But I can't find a good way to get the list of parameters in the right order...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions