Open
Description
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?