LSQCURVET with some fixed parameters

3 views (last 30 days)
Hi, I am trying to fit some (X0, Y0, error and weight W0=1.error) data with a model composed by three functions.
Two of these functions are also convoluted for a resolution function. Since I have 11 free prameters, I tried to fix two of them, but I get some of the paramters out of the bounds, and so I guess I am making some mistakes. My function model is composed by a first part:
y_t=model1(model1_par,x) + model2(model2_par,x);
This part is convoluted for the resolution function, yielding y_conv; I add a constant background and then minimize the following quantity :
y=(y_conv+const_bkg(PAR(1),x)).*w; %(w=1./error).
My three models have the following parameters:
- const_bckg_par = [PAR(1)]
- model1_par = [PAR(2) PAR(3) PAR(4)];
- model2_par = [PAR(5) PAR(6) PAR(7) PAR(8) PAR(9) PAR(10) PAR(11)];
I made a first fit with this model, results are reasonable but not fully satisfying. I tried to reduce the number of parameters, by fixing two of them:
PAR(1): bckg = 5.9135e-04
PAR(4): wD = 11.6
The initial values of the free parameters and lb, ub have now 9 elements corresponding to the previous: [PAR(2) PAR(3) PAR(5) PAR(6) PAR(7) PAR(8) PAR(9) PAR(10) PAR(11)]:
start_val=[ 0.1 2 0.1 0.2 0.2 0.3 0.01 0.1 5.5 ];
lower_lim=[ 1e-5 0 0 0 0 0 0 0 0];
upper_lim=[ 1e-0 10 2 1 5 1 1 1 10];
The model needs 11 parameters, then to keep two of them fixed, I define:
guess=[bckg,start_val(1:2),wD,start_val(3:9)];
and fit with
[ff,resnorm,residual,exitf,out,lam,jac]=lsqcurvefit(@model,...
guess,X0,Y0,lower_lim,upper_lim,opt,sigma,1,ones(size(W0)));
sigma,1,ones(size(W0)) are needed for the convolution.
I get some reasonable numbers compared with previous results, but also a few non-sense ones, completely out of the bounds:
0.0006 0.1038 0.5392 0.4817 0.4593 0.0502 0.2719 0.0434 3.6068 -260.7999 0.0049
In this case, also one of the two fixed parameters (PAR(4)=11.6) is not returned correctly.
Any idea about the error I'm doing?
Thanks!
Nando

Accepted Answer

Matt J
Matt J on 8 Apr 2019
Edited: Matt J on 8 Apr 2019
The initial values of the free parameters and lb, ub have now 9 elements
Do not reduce the length of any vectors to 9 elements. Just use equal upper and lower bounds to limit PAR1 and PAR4 to the desired known values.
lower_lim([1,4])=[bckg,wD]; %an 11-element vector
upper_lim([1,4])=[bckg,wD]; %an 11-element vector
  3 Comments
Matt J
Matt J on 9 Apr 2019
You're welcome, but please Accept-click the answer, if it helped you.
Matt J
Matt J on 9 Apr 2019
understood that it was better avoiding to fix a parameter in this way, that's why I did not try to use the recipe you suggest.
In old Matlab versions, it might have been sub-optimal. However, lsqcurvefit is now smart enough to reduce the dimension of the problem, in the same way that you were trying to do, when it sees equal upper and lower bounds. In any case, also, you have a small number of variables - there isn't much savings to be had.

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!