[ad2ce4e] | 1 | .. residuals_help.rst |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 5 | |
---|
| 6 | .. _Assessing_Fit_Quality: |
---|
| 7 | |
---|
| 8 | Assessing Fit Quality |
---|
| 9 | --------------------- |
---|
| 10 | |
---|
| 11 | When performing model-fits to some experimental data it is helpful to be able to |
---|
| 12 | gauge how good an individual fit is, how it compares to a fit of the *same model* |
---|
| 13 | *to another set of data*, or how it compares to a fit of a *different model to the* |
---|
| 14 | *same data*. |
---|
| 15 | |
---|
| 16 | One way is obviously to just inspect the graph of the experimental data and to |
---|
| 17 | see how closely (or not!) the 'theory' calculation matches it. But *SasView* |
---|
| 18 | also provides two other measures of the quality of a fit: |
---|
| 19 | |
---|
[5ed76f8] | 20 | * $\chi^2$ (or 'Chi2'; pronounced 'chi-squared') |
---|
[ad2ce4e] | 21 | * *Residuals* |
---|
| 22 | |
---|
| 23 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 24 | |
---|
| 25 | Chi2 |
---|
| 26 | ^^^^ |
---|
| 27 | |
---|
[99ded31] | 28 | $\chi^2$ is a statistical parameter that quantifies the differences between |
---|
| 29 | an observed data set and an expected dataset (or 'theory'). |
---|
[ad2ce4e] | 30 | |
---|
[99ded31] | 31 | When showing the a model with the data, *SasView* displays this parameter |
---|
| 32 | normalized to the number of data points, $N_\mathrm{pts}$ such that |
---|
[ad2ce4e] | 33 | |
---|
[5ed76f8] | 34 | .. math:: |
---|
[ad2ce4e] | 35 | |
---|
[99ded31] | 36 | \chi^2_N |
---|
| 37 | = \sum[(Y_i - \mathrm{theory}_i)^2 / \mathrm{error}_i^2] / N_\mathrm{pts} |
---|
[5ed76f8] | 38 | |
---|
[99ded31] | 39 | When performing a fit, *SasView* instead displays the reduced $\chi^2_R$, |
---|
| 40 | which takes into account the number of fitting parameters $N_\mathrm{par}$ |
---|
| 41 | (to calculate the number of 'degrees of freedom'). This is computed as |
---|
[ad2ce4e] | 42 | |
---|
[99ded31] | 43 | .. math:: |
---|
| 44 | |
---|
| 45 | \chi^2_R |
---|
| 46 | = \sum[(Y_i - \mathrm{theory}_i)^2 / \mathrm{error}_i^2] |
---|
| 47 | / [N_\mathrm{pts} - N_\mathrm{par}] |
---|
| 48 | |
---|
| 49 | The normalized $\chi^2_N$ and the reduced $\chi^2_R$ are very close to each |
---|
| 50 | other when $N_\mathrm{pts} \gg N_\mathrm{par}$. |
---|
[ad2ce4e] | 51 | |
---|
[99ded31] | 52 | For a good fit, $\chi^2_R$ tends to 1. |
---|
| 53 | |
---|
| 54 | $\chi^2_R$ is sometimes referred to as the 'goodness-of-fit' parameter. |
---|
[ad2ce4e] | 55 | |
---|
| 56 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 57 | |
---|
| 58 | Residuals |
---|
| 59 | ^^^^^^^^^ |
---|
| 60 | |
---|
| 61 | A residual is the difference between an observed value and an estimate of that |
---|
[99ded31] | 62 | value, such as a 'theory' calculation (whereas the difference between an |
---|
| 63 | observed value and its *true* value is its error). |
---|
[ad2ce4e] | 64 | |
---|
[5ed76f8] | 65 | *SasView* calculates 'normalized residuals', $R_i$, for each data point in the |
---|
[ad2ce4e] | 66 | fit: |
---|
| 67 | |
---|
[5ed76f8] | 68 | .. math:: |
---|
| 69 | |
---|
[99ded31] | 70 | R_i = (Y_i - \mathrm{theory}_i) / \mathrm{error}_i |
---|
| 71 | |
---|
| 72 | Think of each normalized residual as the number of standard deviations |
---|
| 73 | between the measured value and the theory. For a good fit, 68% of $R_i$ |
---|
| 74 | will be within one standard deviation, which will show up in the Residuals |
---|
| 75 | plot as $R_i$ values between $-1$ and $+1$. Almost all the values should |
---|
| 76 | be between $-3$ and $+3$. |
---|
[ad2ce4e] | 77 | |
---|
[99ded31] | 78 | Residuals values larger than $\pm 3$ indicate that the model |
---|
| 79 | is not fit correctly, the wrong model was chosen (e.g., because there is |
---|
| 80 | more than one phase in your system), or there are problems in |
---|
| 81 | the data reduction. Since the goodness of fit is calculated from the |
---|
| 82 | sum-squared residuals, these extreme values will drive the choice of fit |
---|
| 83 | parameters. Any uncertainties calculated for the fitting parameters will |
---|
| 84 | be meaningless. |
---|
[ad2ce4e] | 85 | |
---|
| 86 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 87 | |
---|
[99ded31] | 88 | *Document History* |
---|
| 89 | |
---|
| 90 | | 2015-06-08 Steve King |
---|
| 91 | | 2017-09-28 Paul Kienzle |
---|