Trace:

fitting

This shows you the differences between two versions of the page.

Both sides previous revision Previous revision Next revision | Previous revision | ||

fitting [Mon Jun 3 16:30:29 2013] Alexander |
fitting [Tue Apr 7 17:12:13 2020] (current) Alexander |
||
---|---|---|---|

Line 2: | Line 2: | ||

===== Creating a Fit Plot ===== | ===== Creating a Fit Plot ===== | ||

- | Nonlinear least squares data fitting can be performed using Fit Plot. | + | Nonlinear least squares data fitting (nonlinear regression) can be performed using Fit Plot. |

- | To create a Fit Plot, select your X and Y columns in Table, then select '' | + | To create a Fit Plot, select your X and Y columns in Table, then select ''the main menu, or use the same item in the Table context menu, or use '' |

- | {{: | + | {{:?nolink|Creating Fit Plot using Table context menu}} |

==== MagicPlot has been verified with NIST Datasets ==== | ==== MagicPlot has been verified with NIST Datasets ==== | ||

- | National Institute of Standards and Technology (NIST) has created Statistical Reference Datasets Project which includes [[http:// | + | National Institute of Standards and Technology (NIST) has created the Statistical Reference Datasets Project which includes [[http://Our report on MagicPlot testing with NIST datasets is available here: [[http://Report]]. |

- | | + | |

- | * [[http://PDF report on this testing]]. | + | |

- | * If you want to run these tests on your computer download and open this MagicPlot project file: [[http://]]. | + | |

===== Fitting Methodology ===== | ===== Fitting Methodology ===== | ||

' | ' | ||

- | Fit procedure iteratively varies the parameters of fit function to minimize the residual sum of squares. Nonlinear fitting algorithm needs the user to set the initial values of fit parameters. | + | Fit procedure iteratively varies the parameters of the fit function to minimize the residual sum of squares. The nonlinear fitting algorithm needs the user to set the initial values of fit parameters. |

To fit the data, implement these steps: | To fit the data, implement these steps: | ||

- | - Create a Fit Plot, specify Y errors in Fit Plot properties, if any | + | - Create a Fit Plot, specify Y errors in Data tab of Curve Properties dialog for the data curve, if any |

- Specify fit function by adding Fit Curves | - Specify fit function by adding Fit Curves | ||

- Specify initial values of fit parameters (drag curves or enter accurate values) | - Specify initial values of fit parameters (drag curves or enter accurate values) | ||

Line 30: | Line 26: | ||

This manual does not completely cover the complex nonlinear fitting methodology. We recommend you to take a look at this book: | This manual does not completely cover the complex nonlinear fitting methodology. We recommend you to take a look at this book: | ||

- | * H. Motulsky and A. Christopoulos,.// 2003, GraphPad Software Inc., San Diego CA, graphpad.com. PDF is available for free [[http://www.graphpad.com/ | + | * H. Motulsky and A. Christopoulos,2004.// |

- | {{: | + | {{:?nolink|Fit example}} |

===== Fit Function is a Sum of Fit Curves ===== | ===== Fit Function is a Sum of Fit Curves ===== | ||

Line 39: | Line 35: | ||

Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has three checkboxes: | Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has three checkboxes: | ||

- | {{: | + | {{:?nolink|Fit Curves table}} |

- | * '' | + | * ''the plot. Active only if Baseline checkbox is not set |

* '' | * '' | ||

* '' | * '' | ||

- | Below the Fit Curves list is a parameters table which shows names, values, and descriptions of parameters relating to selected Fit Curve. | + | Below the Fit Curves list, is a parameters table which shows names, values, and descriptions of parameters relating to the selected Fit Curve. |

==== Fitting by Sum and Fitting One Curve ==== | ==== Fitting by Sum and Fitting One Curve ==== | ||

MagicPlot allows two alternatives buttons to run the fit: | MagicPlot allows two alternatives buttons to run the fit: | ||

* '' | * '' | ||

- | * ''Individual interval for each Fit Curve will be used. Set '' | + | * ''The individual interval for each Fit Curve will be used. Set '' |

==== Copying and Pasting Fit Curves ==== | ==== Copying and Pasting Fit Curves ==== | ||

Line 59: | Line 55: | ||

==== Fit Curves Reordering ==== | ==== Fit Curves Reordering ==== | ||

- | You can reorder Fit Curves by dragging them in table. The data curve is always drawn the first and fit sum is drawn the last. | + | You can reorder Fit Curves by dragging them in the table. The data curve is always drawn the first and fit sum is drawn the last. |

===== Setting Initial Values of Parameters ===== | ===== Setting Initial Values of Parameters ===== | ||

- | Nonlinear fitting assumes that certain initial values of parameters are set before fitting. This procedure is very easy if you use Fit Curves of predefined types (not custom equation): you can drag curves on plot. Initial parameters values for each Fit Curve can also be set in parameter table. | + | Nonlinear fitting assumes that certain initial values of parameters are set before fitting. This procedure is very easy if you use Fit Curves of predefined types (not custom equation): you can drag curves on the plot. Initial parameters values for each Fit Curve can also be set in the parameter table. |

- | {{: | + | {{:?nolink|Moving curves with mouse}} |

==== Adjusting Parameters with Mouse Wheel ==== | ==== Adjusting Parameters with Mouse Wheel ==== | ||

- | You can adjust Parameters in table using mouse wheel scrolling when mouse cursor is on the desired parameter: Hold Ctrl key (Cmd key on Mac) and scroll. If Shift key is also pressed the parameter step for one wheel ' | + | You can adjust Parameters in the table using mouse wheel scrolling when the mouse cursor is on the desired parameter: Hold Ctrl key (Cmd key on Mac) and scroll. If the Shift key is also pressed the parameter step for one wheel ' |

===== Guessing Peaks ===== | ===== Guessing Peaks ===== | ||

- | If you are fitting a spectrum with multiple peaks, MagicPlot may automatically add and approximately locate peaks before fitting (Pro edition only). See [[guess_peaks]] for details. Guessed peaks should be used only as the initial estimate for fitting. | + | If you are fitting a spectrum with multiple peaks, MagicPlot may automatically add and approximately locate peaks before fitting (Pro edition only). See [[guess_peaks]] for details. Guessed peaks should be used only as of the initial estimate for fitting: don't forget to click the Fit button after peaks are added. |

===== Parameter Locking ===== | ===== Parameter Locking ===== | ||

- | You can lock (fix) parameter(s) to prevent varying this parameter(s) during fit and to prevent its changing due to setting initial values by mouse dragging (for built-in functions). Set the checkbox in ''parameters list to lock parameter. | + | You can lock (fix) parameter(s) to prevent varying this parameter(s) during the fit and to prevent its changing due to set initial values by mouse dragging (for built-in functions). Set the checkbox in ''the parameter list to lock parameter. |

- | {{: | + | {{:?nolink|Table of Parameters}} |

===== Parameters Joining ===== | ===== Parameters Joining ===== | ||

Line 81: | Line 77: | ||

===== Weighting of Data Points Using Y Errors ===== | ===== Weighting of Data Points Using Y Errors ===== | ||

- | MagicPlot allows data points weighting with Y error data. You can specify Y error data in Fit Plot properties dialog. If no Y error data are specified weighting is not used. | + | MagicPlot allows the weighting of data points with Y error data. You can specify Y error data in Fit Plot properties dialog. If no Y error data are specified weighting is not used. |

Weights are calculated as '' | Weights are calculated as '' | ||

Line 90: | Line 86: | ||

You can set the X intervals of the data which will be used for fitting. Data points outside these intervals are not used to compute the minimizing residual sum of squares. You can use this feature if some data points (especially in the beginning or the end) are inaccurate, e.g. noisy. | You can set the X intervals of the data which will be used for fitting. Data points outside these intervals are not used to compute the minimizing residual sum of squares. You can use this feature if some data points (especially in the beginning or the end) are inaccurate, e.g. noisy. | ||

- | Select '' | + | Select ''the table. |

- | * Double click on interval to split it | + | * Double click on the interval to split it |

* Drag the interval border to move it. If intervals intersect, they will be merged | * Drag the interval border to move it. If intervals intersect, they will be merged | ||

* Use context menu on the plot to create, delete and split intervals | * Use context menu on the plot to create, delete and split intervals | ||

- | **Note:** Data intervals from '' | + | **Note:** Data intervals from the '' |

- | {{: | + | {{:?nolink|Fit interval context menu}} |

===== Baseline Fitting and Extraction ===== | ===== Baseline Fitting and Extraction ===== | ||

- | Fit Interval is also usable when baseline fitting. Before baseline fitting you can specify the interval which does not contain any signal points and contains baseline only. Set '' | + | Fit Interval is also usable when baseline fitting. Before baseline fitting, you can specify the interval which does not contain any signal points and contains baseline only. Set '' |

- | Note that if you use data processing (integration,behaviour to exclude baseline from data before integrating, | + | Note that if you use data processing (integration,behavior to exclude baseline from data before integrating, |

===== ' | ===== ' | ||

Line 111: | Line 107: | ||

===== Viewing the Residual Plot ===== | ===== Viewing the Residual Plot ===== | ||

Residual means here the difference between initial data, baseline function and Fit Sum function. MagicPlot offers two different ways to view the residual: | Residual means here the difference between initial data, baseline function and Fit Sum function. MagicPlot offers two different ways to view the residual: | ||

- | * Press and hold the '' | + | * Press and hold the ''the button is pressed. You can use either mouse or space key (if the button is selected) to hold '' |

* You can either set '' | * You can either set '' | ||

Line 117: | Line 113: | ||

To execute the fit click the '' | To execute the fit click the '' | ||

- | MagicPlot indicates fit process with a special window. Fitting curves are periodically updated on plot while fitting so you can see how fit converges. | + | MagicPlot indicates the fit process with a special window. Fitting curves are periodically updated on the plot while fitting so you can see how fit converges. |

- | {{: | + | {{:?nolink|Fit progress window}} |

- | MagicPlot shows current iteration number and deviation decrement with two progress bars while fit is performed. The fit process stops when one of these progress bars reaches the end. | + | MagicPlot shows the current iteration number and deviation decrement with two progress bars while the fit is performed. The fit process stops when one of these progress bars reaches the end. |

You can see two buttons on fit progress window: | You can see two buttons on fit progress window: | ||

Line 128: | Line 124: | ||

===== Fitting One Curve ===== | ===== Fitting One Curve ===== | ||

- | You can use MagicPlot to fit the data with single selected Fit Curve by pressing '' | + | You can use MagicPlot to fit the data with single selected Fit Curve by pressing '', a specific data interval for each Fit Curve is used and the main fitting data interval (from '' |

- | Because of using individual data interval this method is useful for baseline fitting. In order to fit baseline specify the intervals which does not contain signal (peaks) and contain only noise. | + | Because of using individual data interval this method is useful for baseline fitting. In order to fit baseline specify the intervals which do not contain signal (peaks) and contain only noise. |

- | {{: | + | {{:?nolink|'Fit One Curve' button}} |

===== Why My Fit is Not Converged? ===== | ===== Why My Fit is Not Converged? ===== | ||

- | In some cases the fit procedure may fail to find the optimal parameters values. The actual mathematical reason for this error is impossibility to invert the matrix α calculated from partial derivatives of fit function with respect to fit parameters. This inverted matrix is used to compute the new values of parameters for next step of fit (like gradient descent). In most cases this error occurs when the matrix α is ill-conditioned or nearly singular and the inverse cannot be calculated accurately enough with used floating-point arithmetic. | + | In some cases, the fit procedure may fail to find the optimal parameters values. The actual mathematical reason for this error is the impossibility to invert the matrix α calculated from partial derivatives of the fit function with respect to fit parameters. This inverted matrix is used to compute the new values of parameters for the next step of fit (like gradient descent). In most cases, this error occurs when the matrix α is ill-conditioned or nearly singular and the inverse cannot be calculated accurately enough with used floating-point arithmetic. |

=== The origin of this error may be: === | === The origin of this error may be: === | ||

- | * Fit is not converged through one or more parameters: some parameters were taking unrealistically great values during iterations. There are no local minimum of residual sum of squares near the initial values of these parameters. MagicPlot highlights the suspicious Fit Curve in this case. | + | * Fit is not converged through one or more parameters: some parameters were taking unrealistically great values during iterations. There is no local minimum of residual sum of squares near the initial values of these parameters. MagicPlot highlights the suspicious Fit Curve in this case. |

* Mutual dependency exists between some parameters. The algorithm cannot resolve which parameter to vary. | * Mutual dependency exists between some parameters. The algorithm cannot resolve which parameter to vary. | ||

* Fit function is ill-conditioned: | * Fit function is ill-conditioned: |

fitting.1370262629.txt.gz · Last modified: Sun Nov 8 12:20:32 2015 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International