forum.alglib.net http://forum.alglib.net/ |
|
rep.errpar[0] returns 0 ? http://forum.alglib.net/viewtopic.php?f=2&t=2146 |
Page 1 of 1 |
Author: | dediggefedde [ Mon Sep 29, 2014 2:18 am ] |
Post subject: | rep.errpar[0] returns 0 ? |
Hello! I'm really happy with how easy it seems to be to make nonlinear model fits using your library! However, when I tried to compare the precision to "handmade" calibration for a few datapoints, I noticed that I don't get any parameter-errors! The covariance-matrix is also filled with 0. The state is 2, though, and the returned parameters seem to be nice. I noticed this appears especially, if in theory I have more of a linear equation system than a fit: e.g. 3 points and 3 parameters. However, the real solution is that one parameter is not contributing to the function-value! e.g. I have datapoints like Code: real_2d_array x=[[1,0],[2,0],[3,0]]; real_1d_array y=[0,2.01,4]; real_1d_array c=[1,1,0]; real_1d_array cu=[1e8,1e8,0]; real_1d_array cd=[-1e8,1e8,0]; cu and cd are constraints to make the last parameter fixed. Then I use your libary like in he examples: Code: double epsf = 0; double epsx = 1e-10; ae_int_t maxits = 0; ae_int_t info; lsfitstate state; lsfitreport rep; double diffstep = 1e-7; int differentturns=0; lsfitcreatef(x, y, c, diffstep, state); lsfitsetcond(state, epsf, epsx, maxits); lsfitsetbc(state, cd, cu); alglib::lsfitfit(state, function_cx_1_func); lsfitresults(state, info, c, rep); with the function Code: void function_cx_1_func(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr) { func = c[0]*pow(x[0]+c[1],2)/pow(1+c[2]*x[1],2); } As you can see, the solution would be c=[2,1,0]. This is also working, but rep.errpar[0] and so on is 0. But how can it be 0 if there are 3 datapoints and effectively only 2 parameters to fit? If I would add another datapoint, I would be given a parameter-error. The only solution I currently see would be analyzing the data before fitting and reformatting x and c in case all x[i][1] would be 0. But what would happen, if another parameter would get 0? I guess I won't get parameter-errors then either... Is there anything I missed when using the alglib library or is this even a mathematical problem I'm not aware of? ^^ |
Author: | Sergey.Bochkanov [ Mon Sep 29, 2014 7:53 am ] |
Post subject: | Re: rep.errpar[0] returns 0 ? |
Hello! Errors in parameters are reported only when number of data points is strictly greater than number of parameters. Furthermore, you won't get meaningful estimates with just 4 points - generally, number of points should be orders of magnitude larger than number of parameters to get accurate estimates. These are statistical estimates of error, not exact analytic ones, so they become accurate only when working with large samples (law of large numbers). In you example these estimates should be just ignored. |
Author: | alexender [ Thu Dec 18, 2014 7:18 am ] |
Post subject: | Re: rep.errpar[0] returns 0 ? |
In you example these estimates should be just ignored. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |