Sunday, 8 September 2013

matlab improving curve fitting of a parametric function

matlab improving curve fitting of a parametric function

I've written a script in matlab to fit a parametric function. I would like
to give me
This is the code for fitting:
if individualFit
% Calculate the number of output columns
nbParams = length(parameters);
nbColumns = 17+nbParams;
% Calculate the number of valid persons in the group
nbValidPersons = length(validPersons);
personalFits = cell(nbValidPersons,nbColumns);
validFitPersons = true(nbValidPersons,1);
for i=1:nbValidPersons
personalData = data{validPersons(i),3};
personalData = personalData(personalData(:,1)>=minAge,:);
% Fit a specific model for all valid persons
try
options=optimset();
if LMAlgorithm
'levenberg-marquardt',.001
options=optimset('Algorithm','levenberg-marquardt');
end
[personalParams,personalRes,personalResidual] =
lsqcurvefit(heightModel,initialValues,personalData(:,1),personalData(:,2),[],[],options);
catch
x=1;
end
This is the code where the model is uploaded:
strcmpi(model,'jpa2')
% y = a.*(1-1/(1+(b_1(t+e))^c_1+(b_2(t+e))^c_2+(b_3(t+e))^c_3))
heightModel = @(params,ages) abs(params(1).*(1-1./(1+(params(2).*
(ages+params(8) )).^params(5) +(params(3).* (ages+params(8)
)).^params(6) +(params(4) .*(ages+params(8) )).^params(7) )));
modelStrings = {'a','b1','b2','b3','c1','c2','c3','e'};
% Define initial values
if strcmpi('male',gender)
initialValues = [175 0.35 0.12 0.076 0.43 2.8 20 0.34];
else
initialValues = [162 0.43 0.13 0.089 0.48 2.9 16 0.4];
end
What I would like to improve is the quality of the fitting, more specific
this part:
How can I change the lsqcurvefit command in such a way that it takes much
more time to fit a curve but that the chisquare of the curve is much
lower?
-decreasing parameter ë gave no different results, if I'm using this
correctly.
options=optimset();
if LMAlgorithm
'levenberg-marquardt',.001
options=optimset('Algorithm','levenberg-marquardt');
end
[personalParams,personalRes,personalResidual] =
lsqcurvefit(heightModel,initialValues,personalData(:,1),personalData(:,2),[],[],options);
catch
-following options also didn't improve my fitting.
tolval = 1e-7
itermax = 1e4
options=optimset('DerivativeCheck','off','MaxIter',itermax,...
'Jacobian','on','TolX',tolval,'MaxFunEvals',itermax,'TolFun',...
tolval,'Display','off','FunValCheck','off','DiffMinChange',tolval);
using the means from the good fitted models to determinated the starting
values also gave no (initials
However the quality of fitting stays the same.
Any help?

No comments:

Post a Comment