Is this the correct optimization tool (lsqcurvefit,MultiStart)
Show older comments
I have checked the Optimization tool box to see which one would be good for my optimization problem, so I thought lsqcurvefit would be good for my problem. Upon making a model with data with known parameters and trying to fit it with a model. The parameters estimated are not the same as the known parameters (or converge to the known parameters) that I first created the noisy data. What do you think is wrong with this? I'm also using MultiStart to find different initial points also.
%Creating data with noise:
tu is a (225x3) data
tdata is 225x1 =tu(:,1);
ptest=[0.2,0.1,0.25,0.05];
Tissue= odefnc_noise(ptest,tdata,tu);
%Fitting the data with noise
fun = @(p,tdatas) odefnc_test(p,tdatas,tu);
param0=[0.1 0.1 0.1 0.1];
problem = createOptimProblem('lsqcurvefit','objective',fun,...
'xdata',tdata,'ydata',Tissue,'x0',param0,'lb',[0 0 0 0],'ub',[1 1 1 1],...
'options',options);
[b,fval,exitflag,output,solutions]=run(ms,problem,2);
%Fitting Function
function Tissue= odefnc_test(p,texp,tu)
F=p(1);
fp=p(2);
fis=p(3);
PS=p(4);
init = [0 0];
[~,y]=ode45(@(t,x) myeqn(t,x,F,fp,fis,PS,tu), texp, init);
P=y(:,1);
I=y(:,2);
Tissue = (I+P);
function dx=myeqn(t,x,F,fp,fis,PS,tu)
output=interp1(tu(:,1),tu(:,2),t);
dx(1)= (F/fp)*(output-x(1))- (PS/fp)*(x(1)-x(2));
dx(2)= (PS/fis) *(x(1)-x(2));
dx=[dx(1);dx(2)];
end
end
This will converge to different value even if param0=ptest. So is it the ode function that create a problem? If 'fun' is not an ode, so it is like fun=@(b) b(1)*xdata +b(2)*xdata^2, the solution would converge according to many other problems I found online.
16 Comments
Matt J
on 11 Jun 2017
If the data is noisy, one can't expect the true parameters to be exactly recovered. There will be some error in the estimate due to the noise.
Walter Roberson
on 12 Jun 2017
Right, even with gaussian noise the recovered parameters will seldom exactly equal the original parameters.
Walter Roberson
on 12 Jun 2017
Please post the code for odefnc_noise; also if you could post tu and tdata values for us to test with.
Arbol
on 13 Jun 2017
Walter Roberson
on 13 Jun 2017
Edited: Walter Roberson
on 13 Jun 2017
We do not have your options or your ms
You have
Tissue = (I'+P')+noise;
Here, I, P and noise are all column vectors. The (I'+P') would be a row vector. You would then be adding a row vector and a column vector. In R2016a and earlier that would be an error; in R2016b and later it is the equivalent of
bsxfun(@plus, (I'+P'), noise)
which would produce a 225 x 225 output. The 225 x 225 output would be a problem in later steps.
Walter Roberson
on 13 Jun 2017
Please post your construction of ms which is probably a MultiStart object.
Also, to check, did you change
Tissue = (I'+P')+noise;
to
Tissue = (I+P)+noise;
?
Arbol
on 13 Jun 2017
Arbol
on 13 Jun 2017
Walter Roberson
on 13 Jun 2017
Your tolerance is set to 2E-15, but your function values are coming out on the order of 50000 or 100000 in the areas being explored, so your tolerance is much lower than eps() of the function values. You will therefore be unable to converge and you will just exhaust your maximum function calls or maximum interations. Then the multistart process will notice that the calls all failed to converge and will refuse to run any more locations.
Arbol
on 13 Jun 2017
Arbol
on 13 Jun 2017
Walter Roberson
on 14 Jun 2017
I have not run with your modifications yet. With the version before them, when I changed the tolerance and step size tolerance to some that looked reasonable, nearly all of the runs end with "Change in x was less than the specified tolerance." which is exit 2; the remaining run was at a higher function value and ran out of iterations (exit 0).
I pushed up the number of starts to 20, but by random chance the final output was not better than one of the runs with only 2 multistarts -- so the starting position is important.
Arbol
on 14 Jun 2017
Answers (0)
Categories
Find more on Production Planning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!