Simultaneously fitting two non-linear equations with shared model coefficients
Afficher commentaires plus anciens
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
Torsten
le 19 Juil 2023
F = [f_p, f_v];
instead of
F = [f_p; f_v];
De Ar
le 19 Juil 2023
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".
De Ar
le 19 Juil 2023
Torsten
le 19 Juil 2023
Ok. Then use x0 = [0 0 0 0] as initial guess and see what happens.
Star Strider
le 19 Juil 2023
Another option is something like this:
res(~isfinite(res)) NaN;
res = fillmissing(res,'nearest');
De Ar
le 19 Juil 2023
Réponses (1)
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
De Ar
le 25 Juil 2023
Torsten
le 25 Juil 2023
- 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)),...)
- Use F = [f_p, f_v]; instead of F = [f_p; f_v];
- 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)))
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."
Catégories
En savoir plus sur Linear Least Squares dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!