Simultaneously fitting two non-linear equations with shared model coefficients

I have a pair of non-linear equations with shared model coefficients , representing a two-compartment model, that needs to be fitted to two different datasets of different sizes:
where (representing surviving fraction) is a response variable, (representing dose in Gy) and (representing dose gradient in Gy/cm) are independent variables and is a model coefficient for dataset . Here, the variables for dataset are all known and of size , while for dataset are all known and of size , where . The response variables lies within the range , whereas the independent variables are all positive.
How can I estimate the model coefficients (i.e. )?
Many thanks in advance for any guidance and consideration!
Attempt:
D_p = ... ; % size (1 x N_p)
D_v = ... ; % size (1 x N_v)
G_p = ... ; % size (1 x N_p)
G_v = ... ; % size (1 x N_v)
SF_p = ... ; % size (1 x N_p)
SF_v = ... ; % size (1 x N_v)
x0 = [0.1, 0.01, 0.00001, 0.00001]; % [alpha, beta, delta_p, delta_v]
x = lsqnonlin(@(params) modelfunc(params, D_p, D_v, G_p, G_v, SF_p, SF_v), x0);
function [F] = modelfunc(params, D_p, D_v, G_p, G_v, SF_p, SF_v)
alpha = params(1);
beta = params(2);
delta_p = params(3);
delta_v = params(4);
f_p = SF_p - exp(-alpha.*D_p - beta.*(D_p.^2) + delta_p.*G_p);
f_v = SF_v - exp(-alpha.*D_v - beta.*(D_v.^2) + delta_v.*G_v);
F = [f_p; f_v];
end

7 commentaires

F = [f_p, f_v];
instead of
F = [f_p; f_v];
Thank you for the swift response! Yes, I tried that. However, I am getting the following error:
Error using lsqncommon
Objective function is returning undefined values at initial point. lsqnonlin cannot continue.
Error in lsqnonlin (line 260)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,...
Then either your data contain NaN or Inf values or the parameters are such that you get an over- / underflow in evaluating the exp(...) expressions in "modelfunc".
Before calling "lsqnonlin", set the command
res = modelfunc(x0, D_p, D_v, G_p, G_v, SF_p, SF_v)
in your code and see what is returned in "res".
Thanks. The variable "res" contain -Inf values.
Ok. Then use x0 = [0 0 0 0] as initial guess and see what happens.
Another option is something like this:
res(~isfinite(res)) NaN;
res = fillmissing(res,'nearest');
Choose whatever fillmissing fill method is most appropriate.
Had some normalization problems with SF_p and SF_v - it is now fixed. The range of "res" is between -1 and 1. Still, when running lsqnonlin(@(params) modelfunc(params, D_p, D_v, G_p, G_v, SF_p, SF_v), [0,0,0,0]), I am getting:
Error using lsqncommon
Objective function is returning undefined values at initial point. lsqnonlin cannot continue.

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 19 Juil 2023
Modifié(e) : Matt J le 19 Juil 2023
Since the error message is complaining about the initial point, you should check the value of modelfunc() at the initial point.
Generally speaking though, your initial guess looks somewhat arbitrary. Since your model is log-linear, I would choose the initial point by fitting log(SF) to a linear model, using lsqlin, which doesn't require an initial guess. You should also consider putting bounds or linear inequality constraints on the parameters to prevent the underflow and overflow of the exp() operations which Torsten was referring to.

3 commentaires

The reason I did not fit log(SF) to a linear model is because SF contains 0 values, which are quite essential in the analysis. Knowing this, and in case of using lsqlin, how can the data be fitted to a linear model?
Also, I tried to put (various) reasonable initial points, lower and upper bounds for the parameters when using lsqnonlin. However, I am still getting:
Error using lsqncommon
Objective function is returning undefined values at initial point. lsqnonlin cannot continue.
Error in lsqnonlin (line 260)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,...
Any input as how I should proceed forward?
  1. Check your input arrays D_p, D_v, G_p, G_v, SF_p, SF_v for Inf or NaN values (any(isinf(D_p)),any(isnan(D_p)),...)
  2. Use F = [f_p, f_v]; instead of F = [f_p; f_v];
  3. Try
D_p = ... ; % size (1 x N_p)
D_v = ... ; % size (1 x N_v)
G_p = ... ; % size (1 x N_p)
G_v = ... ; % size (1 x N_v)
SF_p = ... ; % size (1 x N_p)
SF_v = ... ; % size (1 x N_v)
x0 = [0.1, 0.01, 0.00001, 0.00001]; % [alpha, beta, delta_p, delta_v]
res = modelfunc(x0, D_p, D_v, G_p, G_v, SF_p, SF_v)
and inspect "res" for Inf or NaN values (any(isinf(res)),any(isnan(res)))
Matt J
Matt J le 25 Juil 2023
Modifié(e) : Matt J le 25 Juil 2023
The reason I did not fit log(SF) to a linear model is because SF contains 0 values, which are quite essential in the analysis.
SF should never be zero if SF=exp(....something...). Those data should probably be discarded.
However, I am still getting..Objective function is returning undefined values at initial point.
My advice on that has not changed: "you should check the value of modelfunc() at the initial point."

Connectez-vous pour commenter.

Produits

Version

R2022a

Question posée :

le 19 Juil 2023

Modifié(e) :

le 25 Juil 2023

Community Treasure Hunt

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

Start Hunting!

Translated by