matlab curve fitting: restrictions on parameters
I have 5 non-parametric models all with 5 to 8 parameters. This models are
used to fit longitudinal data y(t) with t being time. Every datafile is
fitted by all 5 models for comparison. The model itself cannot be altered.
For fitting starting values are used and these are fitted into a
lsqcurvefit model using a levenberg-marquardt algortihm. So I've written a
script for several models and one function for curvefitting
if i perform the curve fitting a lot of the starting values are wandering
off to extreme values. This is the thing I want to avoid since these
parameters should stay in the proximity off it's starting values and
should only change between a well defined range or so that only curve fits
within a standard deviation are included.Important to note here is that
this restrictions should be imposed during the curve fitting (iterative
numerization techique) and not afterwards.
The function I've written to fit models into height:
% Fit a specific model for all valid persons
try
opts = optimoptions(@lsqcurvefit, 'Algorithm',
'levenberg-marquardt');
[personalParams,personalRes,personalResidual] =
lsqcurvefit(heightModel,initialValues,personalData(:,1),personalData(:,2),[],[],opts);
catch
x=1;
end
The function I've written for one of my models
elseif strcmpi(model,'jpss')
% y =
h_1(1-(1/(1+((t+0.75)^c_1/d_1)+((t+0.75)^c_2/d_2)+((t+0.75)^c_3/d_3)))
% heightModel = @(params,ages)
params(1).*(1-1./(1+((ages+0.75).^params(2))./params(3) +
((ages+0.75).^params(4))./params(5) +
((ages+0.75).^params(6))./params(7)));
heightModel = @(params,ages)
params(1).*(1-1./(1+(((ages+0.75)./params(3)).^params(2)) +
(((ages+0.75)./params(5)).^params(4)) +
((ages+0.75)./params(7)).^params(6))); % Adapted 25/07
modelStrings = {'h1','c1','d1','c2','d2','c3','d3'};
% Define initial values
if strcmpi('male',gender)
initialValues = [174.8 0.6109 2.9743 3.614 9.88 22.393 13.59];
else
initialValues = [162.7 0.6546 2.43 4.011 8.579 18.394 11.846];
end
What I would like to do:
Is it possible to place restrictions on every startingvalue @initial
values? Putting restrictions on lsqcurvefit wouldn't be a good idea I
think since there are different models with different starting values and
different ranges that are allowed.
I had 2 things in my mind: 1. using range and place this between the
initial values initialValues = [162.7 0.6546 2.43 4.011 8.579 18.394
11.846]` if range a1=[150,180]; range a2=[0.3,0.8] and so one
place lb and ub restrictions seperatly on all my initialvalues between
lsqcurvefit if Heightmodel='name model' initial value* 1.2 and lb =
initial value* 0.8
Can someone give me some hints or pointers because I can't make it work.
Thanks in advance
Lucy
Could somebody help me out
No comments:
Post a Comment