[Scilab-users] Error in parameters determined in non-linear least-squares fitting

Heinz Nabielek heinznabielek at me.com
Sat Apr 4 15:13:05 CEST 2020


Scilab friends: the power of Scilab is amazing and I have used it recently for non-linear least-squares fitting, below example from Scilab help function for "datafit". On occasions, I have also used "leastsq".

Question: how do I derive the 1sigma standard error in the three parameters p(1), p(2), and p(3)? And, if it is not too complicated, covariances?

I know this is written in dozens of textbooks, but I am always getting lost.
Please provide a simple recipe written in Scilab.
Best greetings
Heinz



// -- 04/04/2020 14:57:30 -- //
//generate the data
function y=FF(x, p)
  y=p(1)*(x-p(2))+p(3)*x.*x
endfunction
X=[];
Y=[];
pg=[34;12;14] //parameter used to generate data
for x=0:.1:3
  Y=[Y,FF(x,pg)+100*(rand()-.5)];
  X=[X,x];
end
Z=[Y;X];
//The criterion function
function e=G(p, z),
  y=z(1),x=z(2);
  e=y-FF(x,p),
endfunction
//Solve the problem
p0=[3;5;10]
[p,err]=datafit(G,Z,p0);
scf(0);clf()
plot2d(X,FF(X,pg),5) //the curve without noise
plot2d(X,Y,-1)  // the noisy data
plot2d(X,FF(X,p),12) //the solution
xgrid();legend("the curve without noise"," the noisy data", "THE FINAL SOLUTION.....",4);
title("solution set   39.868419    10.312053    11.482521","fontsize",4);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200404/265fb83b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-2.tiff
Type: image/tiff
Size: 39064 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20200404/265fb83b/attachment.tiff>


More information about the users mailing list