problem with leasqr fitting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with leasqr fitting

Octave - General mailing list
Hello,

I am trying to perform a fitting and I am obtaining the following results
pfit1 =

   375.11773
    83.26345
     0.29860

kvg = 1
iter =  3
corp1 =

    NA    NA    NA
    NA    NA    NA
    NA    NA    NA

covp1 =

    NA    NA    NA
    NA    NA    NA
    NA    NA    NA

I attach the data for consideration

thanks

datam= xlsread ('data1.xlsx');

temp=datam(1:173,1)+273;
[intensity, lambda] = regdatasmooth (temp, datam(1:173,2));

k=8.6170e-005;

[pks, loc]=findpeaks (intensity,"DoubleSided");

imaxi=intensity(loc(index=find(pks==max(pks))));
tmaxi=temp(loc(index=find(pks==max(pks))));


eacti1= 0.2;

parTLi1 = [tmaxi,imaxi,eacti1];

F1=@(temp,parTLi1)(imaxi*exp(1+parTLi1(3)./(k*temp).*(temp-parTLi1(1))/parTLi1(1)-temp.^2/parTLi1(1).^2*(1-(2*k*parTLi1(1))/parTLi1(3)).*exp(parTLi1(3)./(k*temp).*(temp-parTLi1(1))/parTLi1(1))-(2*k*parTLi1(1)/parTLi1(3))));

wt_tl=ones(size(temp));
iter_tl=800;
tol_tl=0.1;
dFdp_tl="dfdp";
dp_tl=0.0001*ones(size(parTLi1));

%tolerance
tmax_max=tmaxi+2;
tmax_min=tmaxi-2;
imax_max=imaxi+100;
imax_min=imaxi-100;
eact_max=1.3;
eact_min=0.5;

bounds= [tmax_min,tmax_max; imax_min, imax_max; eact_min,eact_max];


f2=0;

[f2, pfit1, kvg, iter, corp1, covp1, covr1,r2] = leasqr (temp, intensity,
parTLi1, F1,tol_tl, iter_tl,wt_tl, dp_tl, dFdp_tl, bounds)

data1.xlsx <https://octave.1599824.n4.nabble.com/file/t372706/data1.xlsx>  




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: problem with leasqr fitting

Octave - General mailing list

If you plot (temp,intensity,temp,f2) it does a so-so job of fitting your data. Are you concerned about corp1 and covp1?

Your model does not seem to conform very well with the data, so probably the minimum is very shallow and parameters are poorly correlated.

NB, the code uses data-smoothing and signal packages, so they need to be loaded to replicate.

On 3/18/21 9:07 AM, mrodrig via Help-octave wrote:
Hello,

I am trying to perform a fitting and I am obtaining the following results
pfit1 =

   375.11773
    83.26345
     0.29860

kvg = 1
iter =  3
corp1 =

    NA    NA    NA
    NA    NA    NA
    NA    NA    NA

covp1 =

    NA    NA    NA
    NA    NA    NA
    NA    NA    NA

I attach the data for consideration

thanks

datam= xlsread ('data1.xlsx');

temp=datam(1:173,1)+273;
[intensity, lambda] = regdatasmooth (temp, datam(1:173,2));

k=8.6170e-005;

[pks, loc]=findpeaks (intensity,"DoubleSided");

imaxi=intensity(loc(index=find(pks==max(pks))));
tmaxi=temp(loc(index=find(pks==max(pks))));


eacti1= 0.2;

parTLi1 = [tmaxi,imaxi,eacti1];

F1=@(temp,parTLi1)(imaxi*exp(1+parTLi1(3)./(k*temp).*(temp-parTLi1(1))/parTLi1(1)-temp.^2/parTLi1(1).^2*(1-(2*k*parTLi1(1))/parTLi1(3)).*exp(parTLi1(3)./(k*temp).*(temp-parTLi1(1))/parTLi1(1))-(2*k*parTLi1(1)/parTLi1(3))));

wt_tl=ones(size(temp));
iter_tl=800;
tol_tl=0.1;
dFdp_tl="dfdp";
dp_tl=0.0001*ones(size(parTLi1));

%tolerance
tmax_max=tmaxi+2;
tmax_min=tmaxi-2;
imax_max=imaxi+100;
imax_min=imaxi-100;
eact_max=1.3;
eact_min=0.5;

bounds= [tmax_min,tmax_max; imax_min, imax_max; eact_min,eact_max];


f2=0;

[f2, pfit1, kvg, iter, corp1, covp1, covr1,r2] = leasqr (temp, intensity,
parTLi1, F1,tol_tl, iter_tl,wt_tl, dp_tl, dFdp_tl, bounds)

data1.xlsx <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Foctave.1599824.n4.nabble.com%2Ffile%2Ft372706%2Fdata1.xlsx&amp;data=04%7C01%7Cprzemek.klosowski%40nist.gov%7C7140ad0b30644b3b3e9608d8ea0eebbd%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C1%7C637516697097434860%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=PnQRU2pg4DSKxlDYcKh8aWz3ipcJtgGP3mCr%2BfiuE08%3D&amp;reserved=0>  




--
Sent from: https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Foctave.1599824.n4.nabble.com%2FOctave-General-f1599825.html&amp;data=04%7C01%7Cprzemek.klosowski%40nist.gov%7C7140ad0b30644b3b3e9608d8ea0eebbd%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C1%7C637516697097444816%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=xGCVHPn%2FtM39xpmVkomnAG54krmlDJ4vSbxQim8Pbp0%3D&amp;reserved=0




Reply | Threaded
Open this post in threaded view
|

Re: problem with leasqr fitting

Octave - General mailing list
Thanks for the reply. I am interested in the values of corp1 and covp1 since
with them I estimate the errors in the determination of certain points of
the curve (tmaxi, imaxi, eacti1). ¿any idea?

I understand that the adjustment is not the best, but it helps me to
evaluate it, for this, I use the R2 criterion

Thanks again



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: problem with leasqr fitting

Olaf Till-2
On Tue, Mar 23, 2021 at 06:41:57AM -0500, mrodrig via Help-octave wrote:
> Thanks for the reply. I am interested in the values of corp1 and covp1 since
> with them I estimate the errors in the determination of certain points of
> the curve (tmaxi, imaxi, eacti1). ¿any idea?

Contrary to leasqr, the combination of nonlin_residmin and
residmin_stat (or nonlin_curvefit and curvefit_stat) is able to
compute some elements of the covariance or correlation matrices of the
parameters even if not all elements are computable. See optim_doc().

(By default, nonlin_residmin/nonlin_curvefit use the same optimization
algortithm as leasqr.)

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



signature.asc (849 bytes) Download Attachment