The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 fits diverges

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
awi Posted - 07/24/2007 : 3:33:56 PM
Origin Version 7 Operating System: Windows XP

I wanted to fit following function:
y=a1*exp(-((x*a2)^2)/3)+(4*pi*a5/(a3*x))*sin(a4*tan^(-1)(x*a3))*gamma(a4)/(1+(x*a3)^2)^(a4/2).
So I defined the following function:
a1*exp(-1/3*(x*a2)^(2))+4*pi*a5*sin(a4*atan(x*a3))*exp(gammaln(a4))/(x*a3)/(1+(x*a3)^(2))^(a4/2.0)+baseline. The initial paramater values were:
a1=30, a2=30, a3=16, a4=0.6, a5= 0.06, baseline=0.05.
The first part of the fit looks OK (defined mainly by the first component), in the second
(x>0.1) the fit strongly diverges from the experimental data. The function is not really complicated, however 5 parameters (partially correlated) it is a lot. Anyway, I can fit it using different programm, but even implementing those values into origin defined function (exactly the same data set) does not result in overlapping with the data. What am I doing wrong (bad gamma definion or tan-1)?
with best regards,

Ana
5   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 07/27/2007 : 11:25:27 AM
Hi Ana,

Unless told otherwise Origin weights each point equally and continues iterating until the sum of the square of the residuals curve reaches a minimum. Your residuals plot shows that the fit deviates much more at small X values than at large X values. Of course that doesn't show up on the fit curve because of the log scale. To emphasize the large X (small Y) points you can use statistical weighting where each point is weighted by 1/Y-value. I'm not sure what that will do to the small X (large Y) fit.

http://www.originlab.com/www/helponline/origin/Before_you_Start_The_Chi-Square_Minimization.htm
quote:
is there anything like Mathematica's machine number that could increase the calculation sensitivity to a small numbers?
I know nothing about Mathematica or its machine number but it's makes sense to me that the precision of the initial parameter values might come into play. This Knowledge Base artice might help on that point...

http://www.originlab.com/www/support/resultstech.aspx?language=English&ID=1066

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/27/2007 11:40:10 AM

Edited by - Mike Buess on 07/27/2007 11:48:17 AM

Edited by - Mike Buess on 07/27/2007 12:10:56 PM
awi Posted - 07/27/2007 : 05:24:02 AM
Hi ,
Thanks Mike.
These are my real results: experimental data, blue one - simulated curve (which parameters were taken as the initial ones for the final fit), and - red one - the final fit. The latter, in the loglog representation, does not look that good, and it took really lot of time and nearly 99%CPU to perform it. I definetely agree there is a problem with overparametrization, but no matter how senseless the obtained paramter would be, the final fit should be better. The fit at high x, where the y values are extremely small, stops to fast, is there anything like Mathematica's machine number that could increase the calculation sensitivity to a small numbers?


Best regards,
Ana
Mike Buess Posted - 07/25/2007 : 5:27:51 PM
quote:
I tried the NAG function for gamma - it was not accepted somehow.
Click the Edit in CodeBuilder button and add #include <OC_nag.h> at the top.

quote:
However, still I can not get reasonable agreement with the real data
When I added just a small amount of noise to my generated dataset I only got an approximate fit as shown below. (Parameters should be 30,30,16,0.6,0.06,0.05 as you quoted at top.) I'm sure that's because your function is overparameterized as explained above. (Dependencies are all very close to 1.) Note: I still do not see the large discrepencies between data and fit curve that you talk about. In fact, the fit in all regions looks pretty good to me. But, because of overparameterization you should be able to attain that apparent fit with many different parameter sets.

Yes, output of atan and input if sin are both radians.



Mike Buess
Origin WebRing Member
awi Posted - 07/25/2007 : 3:20:52 PM
Dear Mike,

Thank you for your extensive help!. Indeed, all parameters can be constrained to the +- 10% of the initial values, a3 is positive.
I tried the NAG function for gamma - it was not accepted somehow.What is more ,I started to have problems with compilation (I did the compilation check)-
the first term was OK, just implementing the second led to a following message:
Error, invalid term
Error, general compile error
Error, error(s) found in compiling function _nlsfFittingFunction.
Anyway, turning to the fitting wizard somehow solved that problem and right now fitting the self-prepared data is as one would expect.However, still I can not get reasonable agreement with the real data - alhough I believe that my initial values are really correct (results from a different programm ). Since the discrepancies occur just at x>0.1 where the y values are really small there (0.001) (the whole range is 0.001 to 3, loglog plot) it is the second term I must have defined wrongly. But the output of the atan function are radians?,which is the input for sinus... ?
Best regards,

Ana
Mike Buess Posted - 07/24/2007 : 11:27:03 PM
Hi Ana,
quote:
What am I doing wrong (bad gamma definion or tan-1)?
Those are OK, although there is a NAG function which finds gamma directly. I created a dataset using your equation and parameters and fitted the dataset to your equation. If I start with the exact parameter values the fitter stops after one or two iterations without changing those values. In that case fit agrees exactly with data as one would expect. If I change the initial values slightly it may take 50 or 60 iterations to reach the true values. Changing the initial values too much prevents the fitter from reaching from the true values, although fit curve usually does not deviate from data as much as you suggest.
quote:
however 5 parameters (partially correlated)
I think that's the key. Even when the fitter reaches the true parameter values the dependencies of a1 through a5 are all nearly 1 which means that the equation is overparameterized. Therefore, your data/parameter space will have many local chi-sqr minima. In order to reach the global minimum you must start out with parameter values that are already very close to true.
quote:
Anyway, I can fit it using different programm
I'm not familiar with all fitting methods but I question whether any fit to such an overparameterized equation can be meaningful. Perhaps you can tighten it up with constraints? For example, a3= 16 and -16 give nearly the same results. Is there a physical reason to constrain a3 to positive values?

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/25/2007 12:15:08 AM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000