Skip to content

ComponentArray instead of NamedArray for mode estimation results? #2363

Open
@ElOceanografo

Description

@ElOceanografo

When doing an MLE or MAP optimization, the resulting ModeResult.values is a NamedArray, from NamedArrays.jl. If the model contains any array-valued parameters, this can be a real pain to work with: each individual element is indexed with its own unique symbol, requiring the user to do some annoying data munging to get them all together. For instance, to extract a matrix called x that is supposed to have size 20 x 10:

...
opt = maximum_likelihood(mymodel)
x_opt = reshape(opt.values[first.(split.(string.(names(opt.values)[1]), "[")) .== "x"], 20, 10)
...

Maybe there's a better way to do this that I don't know about, but wouldn't it be simpler to return the results as a ComponentArray, a data structure designed for just this use case? That would let you simply do:

x_opt = opt.values.x

Is there any compelling reason to prefer a NamedArray here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions