This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fitting [Wed Oct 27 22:35:34 2010] Alexander |
fitting [Thu Jan 14 17:18:27 2021] (current) 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 Fit Plot select x and y columns in table, then select '' | ||
- | 'Nonlinear' means here that analytical | + | ===== Creating a Fit Plot ===== |
+ | Nonlinear | ||
+ | To create | ||
- | To fit the data you must implement these steps: | + | {{: |
- | - Create Fit Plot, specify | + | |
+ | ==== 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 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: | ||
+ | - Create | ||
- 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 3 check boxes: '' | + | * H. Motulsky and A. Christopoulos, //Fitting Models to Biological Data Using Linear and Nonlinear Regression: A Practical Guide to Curve Fitting, 2004.// |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | Below the Fit Curves list is parameters table which shows parameters names, values, descriptions of the selected Fit Curve. | + | {{: |
- | ===== Coping | + | ===== Fit Function is a Sum of Fit Curves |
- | You can copy and paste Fit Curves in curves table as usual. Use context menu in curves table or press '' | + | MagicPlot considers fit function as a **sum** of Fit Curves. Ordinarily in peaks fitting each Fit Curve corresponds to one peak in experimental data. Click the '' |
- | ===== 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 just easy if you use predefined | + | |
- | Initial parameters values for each Fit Curve can also be set in parameters | + | {{: |
- | ===== 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, intervals | + | * '' |
- | * 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 usable | + | ==== 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 | ||
- | ===== Fit One Curve ===== | + | ===== Parameter Locking |
- | You can also use MagicPlot | + | You can lock (fix) parameter(s) |
- | Because | + | {{: |
- | ===== Joining the Parameters | + | ===== Parameters |
- | In some cases you may want to fit the data with two Gauss or Lorentz peaks with the same width but different | + | MagicPlot allows joining (sometimes referred |
- | To join parameters | + | ===== Weighting |
+ | MagicPlot allows the weighting | ||
- | Joined parameters | + | Weights |
- | ===== Fitting Algorithm ===== | + | Weights must be positive and finite for all points so the Y error values must be positive and non-zero (to prevent infinite weights). MagicPlot checks this condition before |
- | MagicPlot uses iterative [[wp> | + | |
- | Fit procedure iteratively varies | + | ===== Specifying |
+ | You can set the X intervals | ||
- | < | + | 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 | ||
- | here: | + | **Note:** Data intervals from the '' |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | * // | + | |
- | < | + | {{: |
- | The calculation of the new guess of parameters on each fit iteration | + | ===== Baseline Fitting and Extraction ===== |
+ | Fit Interval | ||
- | < | + | Note that if you use data processing |
- | To start minimization, | + | ===== ' |
+ | The ' | ||
- | ==== Fit Procedure Stop Criteria ==== | + | Use 'Data-Baseline' |
- | After each iteration except the first MagicPlot evaluates //deviation decrement D//: | + | |
- | + | ||
- | <m>D = delim{|} {{chi^2}_{curr. iter.} / {chi^2}_{prev. iter.} – 1} {|}</ | + | |
- | + | ||
- | Deviation decrement shows how the residual sum of squares (< | + | |
- | + | ||
- | The iterative fit procedure stops on the one of two conditions: | + | |
- | * 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 | + | |
- | + | ||
- | ==== 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 by two progress bars while fit is performed. The fit process | + | |
- | + | ||
- | Two buttons are located on fit progress window: | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | ===== Weighting of y data ===== | + | |
- | MagicPlot can use weighting of //y// values based on y errors // | + | |
- | * If standard //y// errors are **not** specified: all // | + | |
- | * If standard //y// errors // | + | |
- | < | + | ===== 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: | ||
+ | * Press and hold the '' | ||
+ | * You can either set '' | ||
- | here //C// is normalizing coefficient (to make the sum of // | + | ===== Fitting ===== |
+ | To execute | ||
- | < | + | 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. |
- | In '' | + | {{:fit_progress.png? |
- | * Get y errors from table column(s), | + | |
- | * Percent of data for every point, | + | |
- | * Fixed value or Standard deviation --- do not use in weighting because in this case the error values are the same for all data points. | + | |
- | ===== Calculation of Standard Deviation of Fit Parameters ===== | + | 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 standard deviations (//std. dev.//) of fit parameters // | + | |
- | < | + | You can see two buttons on fit progress window: |
+ | * '' | ||
+ | * '' | ||
- | here α is the matrix of partial derivatives of fit function | + | ===== Fitting One Curve ===== |
+ | You can 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 do not contain signal |
- | ===== Undoing | + | {{: |
- | You can undo fit and undo changing initial parameters as usual using Undo function. This feature is usable for 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 // | + | |
===== 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]] |