Chi-Square and reduced chi-square
Dipak Mainali
Moreover, sometimes I am holding one parameter constant to some value to get the fit. how would that change the degrees of freedom.
TO BE MORE SPECIFIC to the situation;
I am averaging 12 points to get one point; and basically have 94 points each obtained from 12 point average. Then i have calculated the std. deviation for each point. Then i divided those std. deviation with the square root of 12 (i.e no. of points used to get each point) to get the std. error. And i am not sure if i am doing right to get the std. error. Can somebody help me to explain these issue? I will appreciate you help very much. I hope I am not overwhelming with too much information. Thanks.
chi-square = ((Yi - Yihat)/wi)^2
Here, Yi refers to your input data, Yihat refers to the corresponding model values, and wi refers to the corresponding weight values.
If your estimate of the weight is correct, then the chi-square should be roughly equal to the number of data points. It is common to report instead the value divided by N or N-1, but Igor doesn't do that.
If your 94 points are the result of averaging (that is, you start out with 12*94 points) then you are correct, DF = 94-4 when you have 4 fit coefficients. If you hold one fit coefficient constant during the fit, then it does not contribute. Then DF = 94-3. If that difference is important to you, you are reading too much into the statistics :)
It looks like you are computing the standard error of the mean correctly.
Note that all of this discussion implies the assumption that the measurement errors have a Normal distribution with zero mean, and that the fit is linear in the coefficients. If you are fitting a nonlinear function, even with normally distributed errors the statistics are approximations only. That means that error reports are approximations of estimations! If your fit function is not too nonlinear the approximation is often quite good, but you need to be aware of this issue.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 7, 2011 at 10:27 am - Permalink
I have one more question.
The fit I am doing is for FRAP analysis. The equation is F(t)= [{F0 + F∞(t/t1/2)}^α]/[1+(t/t1/2)^α]. The t1/2 "is time half". So I have four parameters F0, F∞, t1/2 and α. This equation is I believe non-linear, right?
Moreover, I read the analysis of the FRAP curve written for Igor 6 by Author: Kota Miura.
It has also mentioned that
"Using chi-square obtained by equation, chi-square distribution for N-M degree of freedom can be calculated using incomplete gamma function. Then this distribution gives the probability Q that the chi-squared should exceed a particular chi-square by chance"
I saw the function syntax in Igor ver 6.12 for incomplete gamma function which looks like " gammaInc (a, x [ , upperTail]) ". But I am not sure how to use that function in Igor to calculate the probability q distribution in my case. Would you guide me in this case?
Thanks for your assistance. I am starting to love Igor everyday. I am so glad when I found that we could use this forum to exchange the difficulties we are having.
July 7, 2011 at 08:31 pm - Permalink
Yes, it is.
In Igor, you could execute a command like this:
print gammq(DF/2, V_chisq/2)
Subsitute for "DF" the degrees of freedom from your fit.
Thank you for your kind words.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 8, 2011 at 11:45 am - Permalink
July 8, 2011 at 01:40 pm - Permalink
If I execute these commands:
display junk
CurveFit/M=2/W=0 line, junk/D
print gammq(4, V_chisq/2) // 4 is 8/2; 8 is 10 points - 2 coefficients for a line fit
I get various values depending on the exact noise added by gnoise, but generally between about 0.5 and 0.9. What do you get?
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 8, 2011 at 02:17 pm - Permalink
I have attached the igor experiment.
Just in case if igor doesn't open, I have added the history report below
•Display/L=Res_Left Pool14 vs Time76
•Make/D/N=4/O W_coef
•W_coef[0] = {0.51,0.81,10,1}
•Make/O/T/N=4 T_Constraints
•T_Constraints[0] = {"K0 > 0","K1 > 0","K2 > 0","K3 > 0"}
•FuncFit/NTHR=0/TBOX=768 anom_dif W_coef Pool14[5,98] /X=Time76 /W=Stderr14 /I=1 /D /C=T_Constraints
Fit converged properly
--Curve fit with constraints--
No constraints active or violated
Curve fit with data subrange:
Pool14[5,98]
fit_Pool14= anom_dif(W_coef,x)
W_coef={0.48114,0.81779,5.6143,0.71463}
V_chisq= 8.83914;V_npnts= 94;V_numNaNs= 0;V_numINFs= 0;
V_startRow= 5;V_endRow= 98;
W_sigma={0.014,0.0169,0.925,0.0917}
Coefficient values ± one standard deviation
Fo =0.48114 ± 0.014
Fin =0.81779 ± 0.0169
t12 =5.6143 ± 0.925
al =0.71463 ± 0.0917
•Print gammq(90/2, V_chisq/2)
1
What are those gnoise and do I need to worry about that in data fitting?
Again, I appreciate your help. I am getting closer to the final conclusion of my data fit. Thanks and have a good weekend.
July 8, 2011 at 04:02 pm - Permalink
In fact, I can open the experiment but I can't run it because it lacks the procedure file "Calc".
What is meant by the phrase, "Then this distribution gives the probability Q that the chi-squared should exceed a particular chi-square by chance" is that the weighting wave tells FuncFit to expect a certain level of measurement error. V_chisq is an estimate of the measurement error, and if V_chisq is much larger than expected, it indicates that the model doesn't fit the data well (or that you are overly optimistic in your error estimate, or that the model is too nonlinear). So I think your result is consistent with that- large V_chisq results in low probability that the fit could be that bad by chance- it means the model doesn't fit the data well. The probability of 1 clearly can't really happen, but it may be so close to 1 that roundoff errors make it appear to be 1. That would happen if your are pessimistic about the measurement errors, or if the model is too nonlinear, or by chance the actual errors were small compared to what is expected.
Your fit looks really good, and the measurement errors appear to be pretty small. My guess is nonlinearity- your FRAP model you wrote out in an earlier post has those pesky exponents and such. You might want to investigate these questions using some sort of Monte Carlo technique.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 12, 2011 at 10:00 am - Permalink
The gencurvefit XOP has some code in it to investigate parameter uncertainties with Monte Carlo techniques.
July 12, 2011 at 06:47 pm - Permalink
http://cmci.embl.de/downloads/frap_analysis
Maybe it would be useful to you.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
December 6, 2012 at 02:49 pm - Permalink