MATLAB Answers

Constant parameter setting throws error, or... if I don't set a parameter to constant, but don't change it, does it stay constant?

2 views (last 30 days)
Jim Bosley
Jim Bosley on 12 Nov 2019
Commented: Jim Bosley on 13 Nov 2019
In another thread, I asked about using subject- (group- in SimBiology) dependent parameter values to allow fitting of one part of a model (say, PD), using subject-specific PK parameters.
It turns out you can. I'm doing this this way:
In my input data file, I duplicate my subject number column and call it "Group". In my model, I've added a species called "Group". I've created a dose object that takes the Group value in that extra column and doses the Group species with that value. So during the fit of any subject, the value in Group is that subject's ID number. I've created a setparvalue.m function that accepts a parameter name and the Group number as inputs. In the code, it reads subject numbers, parameter names, and parameter values from a spreadsheet. These three things are all labeled as persistent so that the time-consuming physical read is done only once.
For each parameter, I have a repeat assignment rule
kmAB_12 = setparvalue('kmAB_12',Group)Gr
For subject-specific operation, this rule is set to active and the parameter value constant flag is set to zero. That is, the parameter is used as a variable.
For normal operation, this rule set to inactive and the parameter value constant flag is set to 1 (that is, the parameter is constant).
The inactive rule generates a little red icon showing that it's inactive. That is as expected and is fine. But even when the rule is inactive, an error icon is generated due to the fact that the rule is modifying a constant parameter.
If the following makes sense, I have a suggestion and a question.
Suggestion: Given that an inactive rule does not affect simulation, I would suggest that any error generated should be suppressed when a rule is inactive.
Question: If I leave the parameter variable all the time, but nothing in the model changes that parameter, does the parameter remain constant? That is, could I just set the parameter constant flag to zero and leave it, to suppress errors? Can you fit parameters that aren't set to constant? I don't observe parameter values changing but I was wondering if it could change under any SimBiology scenario.

  0 Comments

Sign in to comment.

Accepted Answer

Arthur Goldsipe
Arthur Goldsipe on 13 Nov 2019
Great feedback as always, Jim.
As for your immediate questions:
"If I leave the parameter variable all the time, but nothing in the model changes that parameter, does the parameter remain constant? That is, could I just set the parameter constant flag to zero and leave it, to suppress errors?"
Yes, you can use this approach so that you have the flexibility of changing the parameter under other scenarios. That's exactly what I would do in the situation you describe.
"Can you fit parameters that aren't set to constant? I don't observe parameter values changing but I was wondering if it could change under any SimBiology scenario."
Yes, when you try to estimate a parameter that is not constant, what you are really estimating is the initial value of that parameter (before application of any rules and doses at time = 0). One annoying thing right now is that SimBiology still allows you to try to estimate this initial value of a parameter that is modified by a repeated assignment or initial assignment rule, even though that doesn't really make sense. It's on my list of issues to improve with our fitting capabilities.

  3 Comments

Jim Bosley
Jim Bosley on 13 Nov 2019
>Great feedback as always, Jim.
Yes, well, I umm.... strive to be confused in useful and interesting ways.
So if I estimate something not set to constant, but that the model does not change via a rule, that's fine, right? As long as it's not modified by an ACTIVE rule?
If not, its not horrible: I can set the parameter to ConstantValue=true, and the rule assigning a value to Active=false. Given that I have ten pk parameters involved, this generates a lot of warnings in the model browser and ugly error icons on the graphical model. But at least, to your point, it is the "You can't modify a parameter with an assignment rule if its set to ConstantValue=true" error. So at least it's pointed out somewhere. I'd prefer it though, if a rule is not active, that it not flag errors on the model screen or in the browser.
I ran your example "Fit a One-Compartment Model to an Individual's PK Profile" in the "as published" way. This estimates a compartment volume and a rate parameter. Good example. I then accessed both the compartment and parameter via sbioroot and set both the compartment's ConstantCapacity and the parameter's ConstantValue flags to false. The optimization gave the same results, if I did it correctly.
Just to be clear: I have endogenous protein and some data let me calculate an undosed value for generation rate and clearance (tissue- and wall-bound protein make this difficult). Then I can use the gen/clear parameters found for each subject to fit some mAB PK parameters by using the group variable (set by dose) and assignment rules set to active. Fitting everything at once is numerically costly and the results are pretty spotty. So if I fit just the endogenous protein gen and clear parameters I get pretty consistent results. Adding them into a fit for the PK parameters (fitting all simultaneously) gives gen/clear parameters that aren't consistent and aren't physiological.
One last thing, an idea. I'd love to have the ability to do a naive pooled fit of subects with dosing. Yes, the resulting "naive" parameters are wrong, but they're probably closer to popPK representative values (that is, exp(theta)) than my guesses are. I could write a script to accept a set of parameters, and then go through each subject and run that subject via script with a dose set by the script, and calculate error for each subject and sum them to provide an error metric to return to an optimization routine, but that's pretty inefficient. Or is there an easy way to do this that I'm missing?
As always, thanks for your clear and effective response and help.
Arthur Goldsipe
Arthur Goldsipe on 13 Nov 2019
Right, you should be ok estimating a parameter that is set to Constant=false, as long as the parameter isn't modified by a rule.
And if I understand correctly, you can do a naive pooled fit with dosing. There's a pooled option for sbiofiot (and fitting programs in the SimBiology Analysis app). You still set up the data and dosing the same way you wook for an unpooled fit. So you still using different dosing for each individual, but you only estimate a single set of parameters that are the same across all individuals. If you need more details on how to do it, let me know (and whether you want details on the command line or GUI approach, or both).

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!