Simultaneously fitting two non-linear equations with shared model coefficients
2 views (last 30 days)
Show older comments
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 Comments
Star Strider
on 19 Jul 2023
Another option is something like this:
res(~isfinite(res)) NaN;
res = fillmissing(res,'nearest');
Answers (1)
Matt J
on 19 Jul 2023
Edited: Matt J
on 19 Jul 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 Comments
Torsten
on 25 Jul 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)))
Matt J
on 25 Jul 2023
Edited: Matt J
on 25 Jul 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."
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!