This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fitting [Mon Feb 14 19:15:27 2011] Alexander |
fitting [Thu Jan 14 17:18:27 2021] Alexander |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Nonlinear Curve Fitting: Fit Plot ====== | ====== Nonlinear Curve Fitting: Fit Plot ====== | ||
- | Nonlinear least squares data fitting can be performed using Fit Plot. | ||
- | To create a Fit Plot, select x and y columns in table, then select '' | ||
- | ' | + | ===== Creating a 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 '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ==== MagicPlot has been verified with NIST Datasets ==== | ||
+ | National Institute of Standards and Technology (NIST) has created the Statistical Reference Datasets Project which includes [[http:// | ||
+ | |||
+ | ===== Fitting Methodology ===== | ||
+ | ' | ||
+ | Fit procedure iteratively varies | ||
To fit the data, implement these steps: | To fit the data, implement these steps: | ||
- | - Create a Fit Plot, specify | + | - Create a Fit Plot, specify |
- 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) | ||
- | - Specify used x data interval | + | - Specify used X data interval |
- Run fitting | - Run fitting | ||
- | {{: | + | You can undo fit and also undo changing initial parameters as any other action using '' |
- | ===== Fit Function is a Sum of Fit Curves ===== | + | ==== Further reading |
- | MagicPlot considers fit function as a **sum** of Fit Curves. Ordinarily in peaks fitting each Fit Curve corresponds | + | This manual does not completely cover the complex nonlinear fitting methodology. We recommend you to take a look at this book: |
- | Fit Plot window contains the list of Fit Curves. Each Fit Curve in the list has three checkboxes: '' | + | |
- | | + | |
- | * '' | + | |
- | * '' | + | |
- | Below the Fit Curves list is a parameters table which shows names, values, and descriptions of parameters relating to selected Fit Curve. | + | {{: |
- | ===== Copying | + | ===== Fit Function is a Sum of Fit Curves ===== |
- | You can copy and paste Fit Curves | + | MagicPlot considers fit function as a **sum** of Fit Curves. |
- | ===== Setting Initial Values | + | Fit Plot window contains the list of Fit Curves. |
- | Nonlinear fitting assumes that certain initial values of parameters are set before fitting. This procedure is very easy if you use predefined | + | |
- | Initial parameters values for each Fit Curve can also be set in parameter | + | {{: |
- | ===== Parameter Locking ===== | + | * '' |
- | You can lock parameter(s) | + | * '' |
+ | * '' | ||
- | ===== Fit Intervals ===== | + | Below the Fit Curves list, is a parameters table which shows names, values, and descriptions |
- | You can set the x intervals | + | |
- | Select | + | ==== Fitting by Sum and Fitting One Curve ==== |
- | * Double click on interval to split it | + | MagicPlot allows two alternatives buttons to run the fit: |
- | * 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 | + | * '' |
- | | {{: | + | ==== Copying and Pasting Fit Curves ==== |
+ | You can copy and paste Fit Curves from one Fit Plot to another Fit Plot or Figure. You can also paste the copied Fit Curves to the same Fit Plot to create a copy. | ||
- | ===== Baseline Fitting and Extraction ===== | + | * The copy of Fit Curves with the same parameters |
- | Fit Interval is also usable when baseline fitting. Before baseline fitting you can specify | + | * A link to the source Fit Curves will be inserted if you paste Fit Curves in a Figure. |
- | The most appropriate | + | ==== Fit Curves Reordering ==== |
+ | You can reorder Fit Curves by dragging them in the table. | ||
- | Note that if you execute one of data processing algorithms | + | ===== Setting Initial Values of Parameters ===== |
+ | Nonlinear fitting assumes | ||
- | ===== ' | + | {{: |
- | The ' | + | |
- | It is 'Data-Baseline' | + | ==== Adjusting Parameters with Mouse Wheel ==== |
+ | You can adjust Parameters in the table using mouse wheel scrolling when the mouse cursor | ||
- | Use ' | + | ===== Guessing Peaks ===== |
+ | If you are fitting a spectrum with multiple peaks, MagicPlot may automatically add and approximately locate peaks before fitting. See [[guess_peaks]] for details. Guessed peaks should be used only as of the initial | ||
- | ===== Viewing the Difference between Data and Fit Sum Function (Residual) | + | ===== Parameter Locking |
- | MagicPlot offers two different ways to view the difference between data and Fit Sum function: | + | You can lock (fix) parameter(s) |
- | * You can set '' | + | |
- | or | + | |
- | * You can press and hold '' | + | |
- | ===== Fit One Curve ===== | + | {{: |
- | You can also use MagicPlot to fit the data with single selected Fit Curve by pressing '' | + | |
- | 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 | + | ===== Parameters Joining ===== |
+ | MagicPlot allows joining | ||
- | ===== Joining the Parameters | + | ===== Weighting |
- | In some cases you may want to fit the data with two Gauss or Lorentz peaks with the same width but different positions and amplitudes, for example. You can do this in two ways: by specifying custom | + | MagicPlot allows |
- | To join parameters of two or more Fit Curves select one of desired Fit Curves, select desired parameter in parameters table and press '' | + | Weights are calculated as '' |
- | Joined parameters are shown with blue color (instead of black) in parameters table. | + | Weights must be positive and finite for all points so the Y error values must be positive and non-zero |
- | ===== Fitting Algorithm | + | ===== Specifying Fit Intervals |
- | MagicPlot uses iterative [[wp> | + | 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 |
- | Fit procedure iteratively varies | + | Select '' |
+ | * Double click on the interval to split it | ||
+ | * 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 | ||
- | < | + | **Note:** Data intervals from the '' |
- | here: | + | {{:interval_context_menu1.png? |
- | * // | + | |
- | * //N// is total number of points, | + | |
- | * //f//(//x, β< | + | |
- | * //p// is the number of fit parameters // | + | |
- | * // | + | |
- | < | + | ===== 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 '' | ||
- | Calculation of the new guess of parameters on each fit iteration is based on the fit function partial derivatives for current values of fit parameters | + | Note that if you use data processing (integration, |
- | < | + | ===== ' |
+ | The ' | ||
- | To start minimization, | + | Use ' |
- | ==== Fit Procedure Stop Criteria | + | ===== Viewing the Residual Plot ===== |
- | After each iteration except | + | Residual means here the difference between initial data, baseline function and Fit Sum function. |
+ | * Press and hold the '' | ||
+ | * You can either set '' | ||
- | < | + | ===== Fitting ===== |
+ | To execute the fit click the '' | ||
- | Deviation decrement shows how the residual sum of squares (< | + | MagicPlot indicates |
- | The iterative fit procedure stops on one of two conditions: | + | {{:fit_progress.png? |
- | * If the deviation decrement //D// is less than minimum allowable deviation decrement, which is 10< | + | |
- | or (and) | + | |
- | * If the number of iterations exceeds maximum number of iterations, which is 100 by default | + | |
- | You can change the minimum allowable deviation decrement and maximum number of iterations in Fitting tab of MagicPlot Preferences. | + | 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. |
- | + | ||
- | ===== Fit Progress Window ===== | + | |
- | + | ||
- | 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 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. | + | |
You can see two buttons on fit progress window: | You can see two buttons on fit progress window: | ||
Line 125: | Line 123: | ||
* '' | * '' | ||
- | ===== Weighting of y data ===== | + | ===== Fitting One Curve ===== |
- | MagicPlot | + | You can use MagicPlot to fit the data with single selected Fit Curve by pressing '' |
- | * If standard //y// errors are **not** specified: all // | + | |
- | * If standard //y// errors // | + | |
- | + | ||
- | < | + | |
- | + | ||
- | here //C// is normalizing coefficient | + | |
- | + | ||
- | < | + | |
- | In '' | + | Because |
- | * Get y errors from table column(s), | + | |
- | * Percent | + | |
- | * Fixed value or Standard deviation --- do not use in weighting because in this case the error values are the same for all data points. | + | |
- | ===== Undoing | + | {{: |
- | You can undo fit and undo changing initial parameters as usual using Undo function. It is a handy feature when experimenting with different models and initial parameters (e.g. peaks positions). | + | |
- | ===== Formulas | + | ===== Why My Fit is Not Converged? |
- | In the table below you can find the formulas which MagicPlot uses to calculate | + | In some cases, |
- | Because | + | === The origin |
+ | * Fit is not converged through one or more parameters: | ||
+ | * Mutual dependency exists between some parameters. The algorithm cannot resolve which parameter to vary. | ||
+ | * Fit function is ill-conditioned: | ||
+ | * Numeric overflow | ||
- | ^ Parameter Name ^ Symbol | + | === Try one of the following: |
- | ^ Original Data and Fit Model Properties | + | |
- | | Number | + | |
- | | Fit parameters | + | |
- | | Number of fit function parameters //β// | < | + | |
- | | [[wp> | + | |
- | | Estimated mean of data | < | + | |
- | | Estimated variance of data | < | + | |
- | | Data total sum of squares, TSS | TSS | < | + | |
- | ^ Fit Result | + | |
- | | Residual sum of squares, < | + | |
- | | Reduced // | + | |
- | | Standard deviation of the model | //s// | < | + | |
- | | [[wp> | + | |
- | | Adjusted // | + | |
- | | Covariance Matrix of Parameters // | + | |
- | | Standard Deviation of Parameters // | + | |
===== See Also ===== | ===== See Also ===== | ||
+ | * [[fit_formulas]] | ||
* [[custom_fit_equation]] | * [[custom_fit_equation]] | ||
* [[spline]] | * [[spline]] | ||
+ | * [[joining]] | ||
* [[guess_peaks]] | * [[guess_peaks]] | ||
* [[fit_equations]] | * [[fit_equations]] | ||
- | * [[transform_xy]] | ||
* [[interval_statistics]] | * [[interval_statistics]] | ||
+ | * [[table_from_curves]] |