basico icon indicating copy to clipboard operation
basico copied to clipboard

Simultaneous Parameter Estimation

Open Theo-BRN opened this issue 1 year ago • 5 comments

Heya, hope you're well!

I was wondering if simultaneous parameter estimation was possible with copasi/basico. For example, if you had two experiments you want to fit to, and of the two parameters to fit (k1 and k2), each experiment has a different k1, but a shared k2. Can you essentially tell copasi "this parameter is the same in both experiments, please fit it" and "this parameter may be different in each experiment, please fit it".

I know you can declare what experiments are affected by a parameter with set_fit_parameters but I'm not sure that's quite the same.

Any clarification, or reference to examples in documentation would be greatly appreciated.

Thanks, Theo

Theo-BRN avatar Apr 18 '24 16:04 Theo-BRN

You are completely right, that is what affected experiments are made for. If not specified the parameter will be assumed to be the same for all experiments. Otherwise that parameter would be only used for the experiments specified. So if you had a different k1, you'd have 2 fit items for k1, with different affected experiments. I hope this makes it clear.

fbergmann avatar Apr 18 '24 17:04 fbergmann

Ah great, thank you for the clarification, that does help!

Is it possible to have a parameter be fitted as shared for some experiments and then independent for the rest? Let's say experiments 1, 2 and 3 share the same k_on variable and experiments 4 and 5 have different k_on variables. Perhaps the fit_parameters argument would look like:

fit_items = [
    {'name': "Values[k_on]", 'lower': 1e05, 'upper': 1e09, 'affected': ['Exp_1, Exp_2, Exp_3']},
    {'name': "Values[k_on]", 'lower': 1e05, 'upper': 1e09, 'affected': ['Exp_4']},
    {'name': "Values[k_on]", 'lower': 1e05, 'upper': 1e09, 'affected': ['Exp_5']},
]

Theo-BRN avatar Apr 19 '24 15:04 Theo-BRN

indeed, but you'd have to write it like:

fit_items = [
    {'name': "Values[k_on]", 'lower': 1e05, 'upper': 1e09, 'affected': ['Exp_1', 'Exp_2', 'Exp_3']},
    {'name': "Values[k_on]", 'lower': 1e05, 'upper': 1e09, 'affected': ['Exp_4']},
    {'name': "Values[k_on]", 'lower': 1e05, 'upper': 1e09, 'affected': ['Exp_5']},
]

fbergmann avatar Apr 19 '24 15:04 fbergmann

Oh of course, tha's just a silly mistake of mine.

In which case that's brilliant functionality! Thank you so much for your help!

Are you able to supply a pandas dataframe to the function instead of a list of dictionaries?

Theo-BRN avatar Apr 19 '24 15:04 Theo-BRN

oh i missed this question. Indeed the fititems can be set as pandas dataframe

fbergmann avatar Jul 03 '24 07:07 fbergmann