Simultaneously fitting two non-linear equations with shared model coefficients
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Star Strider
2023년 7월 19일
Another option is something like this:
res(~isfinite(res)) NaN;
res = fillmissing(res,'nearest');
답변 (1개)
Matt J
2023년 7월 19일
편집: Matt J
2023년 7월 19일
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
Torsten
2023년 7월 25일
- 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
2023년 7월 25일
편집: Matt J
2023년 7월 25일
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."
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!