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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Reduced Chi Squared Value-not right ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cosy

Germany
Posts

Posted - 06/22/2005 :  12:18:32 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Origin 7 PRO
Operating System: Win XP.

Hi,
As far as I know, a reduced chi squared value ( Chi Squared/DOF )of 1 indicates a perfect fit and fits made to any experimental data, due to the noise in it give a value near to 1.But, the results I get from the fitting wizard makes me puzzled.

I made a dataset containing "perfect" linear model values (Y= Ax+B)
and when I fit the LineMod function to it from the Fitting Wizard, the A and B values are correct but the reduced Chi squared values are something like 1,404E-28 in my case, which is totally unacceptable. I would expect a value very close to 1.

Any explanations will be appreciated.

Regards,
Deepak Samuel.

Mike Buess

USA
3037 Posts

Posted - 06/22/2005 :  12:57:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deepak,

Chi-sqr quantifies the deviation of predicted values from the actual values. If there is no deviation (perfect fit) then chi^2=0. Since there must be at least one degree of freedom (DOF>=1) chi^2/DOF=1.4E-28 looks pretty good.

...I can't find the definition of DOF in the manual but it appears to be

DOF=#data points - #fitting parameters

Point is, DOF is usually >> 1 so chi^2/DOF can only be 1 for a lousy fit (chi^2>>1).

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 06/22/2005 1:13:53 PM
Go to Top of Page

easwar

USA
1965 Posts

Posted - 06/22/2005 :  5:48:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

The definition of chi-square, as used in the minimization process and reported in results from fitting, can be found in the Origin help under the topic:
Analysis:Curve Fitting>The NLSF Advanced Fitting Tool>Before you Start: The Chi-Square Minimization.

For the moment, ignorning weighting and multiple dependent vars etc, tbe basic definition is:

Origin-Chi-Square = (1/DOF) * sum( (data value - function value)^2 )

where DOF = number of points - number of parameters.

So as Mike points out, for perfect/near-perfect data (good match of data and model), the chi-sq we report will be a very small number, furthermore because of the division by DOF.

The definition of chi-sq you are considering appears to be different. If you know the formula for that definition (where an ideal fit gives a value of 1), one could look at that and see if that quantity could be reproduced in Origin using the various paramters output by the fitter perhaps.

Easwar
OriginLab

Edited by - easwar on 06/22/2005 5:49:30 PM
Go to Top of Page

cosy

Germany
Posts

Posted - 06/23/2005 :  05:20:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,
Thanks for the clarification. I just took a look at the formula for Reduced Chi squared -
Red.Chi.Sqd.= Chi.Sqd/DOF = estimated variance / Parent variance

If the fitting function is a good approximation to the parent function, then the estimated variance should agree well with the parent variance and the value of reduced chi squared should be approximately unity.

While, in my case there was no need for an approximation as my as my parent function is precisely my fitting function (perfect fit) and so the variance is zero.

Thanks once again for the clarification.

Deepak Samuel.
Go to Top of Page

cosy

Germany
Posts

Posted - 06/23/2005 :  06:01:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Mr. Easwar,
Thanks for your reply too. I think the formula Origin uses to calculate the Red.Chi.Sqd values are not normalised to the weighted average of the individual variances. If the normalisation is carried out then we will arrive at the same value. I think normalisation makes sense as much noisy linear data would lead to huge values in your case. With the normalisation I mentioned it would yield a value pretty close to 1 independent of the noise involved.

In my case the red.chi sqd would look like :

Chi.Sqd/DOF = sum( (data value - function value)^2 /sigma(i)^2)

where sigma (i) is the individual variance.


I think, a goodness of fit test should answer this question :

How good is my choice of the fitting function ?
not
How much is the deviation from the fitting function ?

Though the second question comes close to the first one, its not as reliable as the first.

Please correct me if my view is wrong.

Thanks for your reply and expecting more coments in this regard.
(I use the book by Bevington -Data reduction and error analysis for the Physical sciences. )

Regards,
Deepak Samuel.
quote:

Hi,

The definition of chi-square, as used in the minimization process and reported in results from fitting, can be found in the Origin help under the topic:
Analysis:Curve Fitting>The NLSF Advanced Fitting Tool>Before you Start: The Chi-Square Minimization.

For the moment, ignorning weighting and multiple dependent vars etc, tbe basic definition is:

Origin-Chi-Square = (1/DOF) * sum( (data value - function value)^2 )

where DOF = number of points - number of parameters.

So as Mike points out, for perfect/near-perfect data (good match of data and model), the chi-sq we report will be a very small number, furthermore because of the division by DOF.

The definition of chi-sq you are considering appears to be different. If you know the formula for that definition (where an ideal fit gives a value of 1), one could look at that and see if that quantity could be reproduced in Origin using the various paramters output by the fitter perhaps.

Easwar
OriginLab

Edited by - easwar on 06/22/2005 5:49:30 PM

Go to Top of Page

Leo_Li

China
Posts

Posted - 06/23/2005 :  08:29:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Deepak,

Just want to remind that there is another parameter, so called correlation coefficient (r value), which will be very close to 1 if a fit is perfect.

Leo
Go to Top of Page

easwar

USA
1965 Posts

Posted - 06/23/2005 :  11:58:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

I think the formula Origin uses to calculate the Red.Chi.Sqd values are not normalised to the weighted average of the individual variances. If the normalisation is carried out then we will arrive at the same value. I think normalisation makes sense as much noisy linear data would lead to huge values in your case. With the normalisation I mentioned it would yield a value pretty close to 1 independent of the noise involved.

In my case the red.chi sqd would look like :

Chi.Sqd/DOF = sum( (data value - function value)^2 /sigma(i)^2)

where sigma (i) is the individual variance.


I think, a goodness of fit test should answer this question :

How good is my choice of the fitting function ?
not
How much is the deviation from the fitting function ?

Though the second question comes close to the first one, its not as reliable as the first.

Please correct me if my view is wrong.

Thanks for your reply and expecting more coments in this regard.
(I use the book by Bevington -Data reduction and error analysis for the Physical sciences. )



Hi Deepak,

In my reply yesterday, I was over-simplifying the equation we use. We indeed take care of variances, provided the correct weighting method is used. The formula we use is then exactly what you quote.

The difference is the following:
What we report is Chi-Sq/DOF and what you are referring to is Chi-Sq, which can be obtained by multiplying the chi-sqr value we report by DOF, the number of degrees of freedom.

I had a copy of Bevington handy and I took one of their data tables pasted below and performed the fitting in Origin. Here are the results:

1> I took the xi, Counts and sigma_Ci columns from Table 6.2 (pg 98) of Bevington and placed that in cols X, Y, YErr of the Origin datasheet and created a symbol+err graph
2> I used the NLSF fitting tool in Origin and selected the equation Line (y=a+b*x) from the Polynomial category
3> After assigning dataset etc. I used the Options->Control dialog of the NLSF tool and changed the Weighting Method drop-down to Instrumental. This then takes the values in the YErr column and then takes (1/yerr^2) as the weight.
4> I performed the fit and placed the fit values right next to the worksheet data column (using Scripts->After Fit->Same X as Fit Data radio button in the NLSF tool).

As you can see from Bevington's table and from the Origin wks, the numbers match.

In the Origin image, towards the bottom, is the script window with the formula chisqr*dof. You can see that the chi-sqr value from the Origin fit is 10.93 obtained by multiplying the reported reduced-chi-sq by the degrees of freedom.

This value of 10.93 corresponds to the value of 11.1 reported in the table from Bevington. I attribute this small difference to the fact that the table in Bevington seems to be rounding of the numbers in each of their columns and thus the chi-sqr computed after the round-off is slightly different.

If you then follow the discussion of Chi-Sqr Probability on page 107 of Bevington, and look up the Chi-Sq distribution table C.4 on page 258, you can see that using the reduced chi-sqr value of 1.37 reported by Origin with 8 degrees of freedom, you come up with the probability for the fit to be about 20%, which is the same estimate under footnote in table 6.2

So you just need to
a) make sure the appropriate weighting method is used
b) scale the nlsf.chisqr reported by Origin with DOF to get the raw chi-sqr

Easwar
OriginLab




Go to Top of Page

cosy

Germany
Posts

Posted - 06/24/2005 :  06:03:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Mr. Easwar,
Thanks for the clarification.
Regards,
Deepak Samuel.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000