Message Boards Message Boards

0
|
1439 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Recommended association structure to report fits and fit metrics for multi-component models

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?

POSTED BY: Chase Turner
2 Replies

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 a structure that can be Hashed (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...

POSTED BY: Chase Turner

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, use the Association to create cModelExec:

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} -> 
  10, {A, 1, "CI"} -> {1.1, 1.2}, ... |>

Using a nested Association is possible , but it is prone to errors in construction

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

Attachments:
POSTED BY: Chase Turner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract