UPDATE: I’ve now explored this question with ChatGPT which strongly encourages me to use Nested Associations and avoid the Key problem that a List is not Atomic unless I convert the List into an AtomicKey (e.g., ToString) – which opens its own can of worms for Key Pattern tests, etc.
All that said, I’d welcome your opinion on the matter or, if none arrive in the next day or so, I’ll withdraw this posting and continue forward with Nested Associations…
I’m seeking advice here as to how to employ Associations both for reporting tabular summaries of “BestFitParameters”, “ParameterConfidenceIntervals”, etc for n-component such as:
cModel[n_Integer] /; n >= 1 :=
M + Sum[A[i]*Cos[t*((2*Pi)/tau[i]) + phase[i]], {i, n}]
Also, to derive a cModelExec so that I can calculate estimated values:
cModelExec = Function[t, Evaluate[cModel[2] /. <| M -> 100, tau[1] -> 86400, A[1] -> 10,
phase[1] -> - Pi, tau[2] -> 89280, A[2] -> 3, phase[2] -> - Pi/2|>]]
In the above, sometimes I’m collecting results from a FittedModel; other times, I’m using my own solvers to estimate the fits and fit metrics.
Currently, my thought process is heading me to use flat Associations with Lists as Keys:
-
Using a flat Association is attractive for the ease of a ReplaceAll and avoid collisions on re-used strings such as “CI”, “StdErr”, etc. For example:
<| {tau, 1} -> 86400, {tau, 1, "CI"} -> {29.1, 32.3}, ..., {A, 1, "CI"} -> {1.1, 1.2}, ... |> -
Using a nested Association is possible , but it is prone to errors in construction e.g.
<| tau -> {<|1 -> <|"Value" -> 86400, "CI" -> {29.1, 32.3}, ... |>, 2 -> <|...|>|>}, A -> {<|1 -> <|"CI" -> {1.1, 1.2}, ... |>, 2 -> <|...|>|>}|>
Question: Relative to my requirements listed above, am I heading in the right direction to use a flat association with Lists as keys, or should I be solving my problem here in an entirely different way?